Spaces:
Runtime error
Runtime error
Commit
·
d231a79
1
Parent(s):
1a3ddaa
Update streamlit_config.py
Browse files- 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
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
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)
|
|
|
|