Spaces:
Running
Running
Commit
·
37e92bb
1
Parent(s):
baf7aa0
Update app.py
Browse files
app.py
CHANGED
@@ -29,12 +29,16 @@ image = None # Initialize image variable
|
|
29 |
if opt == 'Upload image from device':
|
30 |
file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
|
31 |
if file is not None:
|
32 |
-
|
|
|
|
|
|
|
33 |
|
34 |
elif opt == 'Upload image via link':
|
35 |
try:
|
36 |
img = st.text_input('Enter the Image Address')
|
37 |
-
|
|
|
38 |
except ValueError:
|
39 |
if st.button('Submit'):
|
40 |
show = st.error("Please Enter a valid Image Address!")
|
|
|
29 |
if opt == 'Upload image from device':
|
30 |
file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
|
31 |
if file is not None:
|
32 |
+
try:
|
33 |
+
image = Image.open(file).resize((256, 256), Image.LANCZOS)
|
34 |
+
except Exception as e:
|
35 |
+
st.error(f"Error: {e}")
|
36 |
|
37 |
elif opt == 'Upload image via link':
|
38 |
try:
|
39 |
img = st.text_input('Enter the Image Address')
|
40 |
+
response = urllib.request.urlopen(img)
|
41 |
+
image = Image.open(response).resize((256, 256), Image.LANCZOS)
|
42 |
except ValueError:
|
43 |
if st.button('Submit'):
|
44 |
show = st.error("Please Enter a valid Image Address!")
|