Quinniboi10 commited on
Commit
d231a79
·
1 Parent(s): 1a3ddaa

Update streamlit_config.py

Browse files
Files changed (1) hide show
  1. streamlit_config.py +23 -25
streamlit_config.py CHANGED
@@ -36,28 +36,26 @@ def run():
36
  img_url = st.text_input('Image URL', 'https://images.unsplash.com/photo-1556911220-bff31c812dba?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2468&q=80')
37
  st.caption('Downloading Image...')
38
  img_data = requests.get(img_url).content
39
- with open('detect.jpg', 'wb') as handler:
40
- handler.write(img_data)
41
- file = Image.open('detect.jpg')
42
- if not file:
43
- return
44
-
45
- placeholder = st.empty()
46
- placeholder.info(
47
- "Processing..."
48
- )
49
-
50
- image = process_file(file)
51
- placeholder.empty()
52
- placeholder.image(image)
53
-
54
- filename = file.name
55
- format = re.findall("\..*$", filename)[0][1:]
56
-
57
- image = Image.fromarray(image)
58
-
59
- buf = BytesIO()
60
- image.save(buf, format="JPEG")
61
- byte_image = buf.getvalue()
62
-
63
- download_button(byte_image, filename, format)
 
36
  img_url = st.text_input('Image URL', 'https://images.unsplash.com/photo-1556911220-bff31c812dba?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2468&q=80')
37
  st.caption('Downloading Image...')
38
  img_data = requests.get(img_url).content
39
+ with open('detect.jpg', 'wb') as file:
40
+ if not file:
41
+ return
42
+
43
+ placeholder = st.empty()
44
+ placeholder.info(
45
+ "Processing..."
46
+ )
47
+
48
+ image = process_file(file)
49
+ placeholder.empty()
50
+ placeholder.image(image)
51
+
52
+ filename = file.name
53
+ format = re.findall("\..*$", filename)[0][1:]
54
+
55
+ image = Image.fromarray(image)
56
+
57
+ buf = BytesIO()
58
+ image.save(buf, format="JPEG")
59
+ byte_image = buf.getvalue()
60
+
61
+ download_button(byte_image, filename, format)