Spaces:
Running
Running
Commit
·
a367aa2
1
Parent(s):
3373046
Update app.py
Browse files
app.py
CHANGED
@@ -29,18 +29,18 @@ opt = st.selectbox("How do you want to upload the image for classification?", ('
|
|
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 |
|
35 |
elif opt == 'Upload image via link':
|
36 |
img_url = st.text_input('Enter the Image Address')
|
37 |
try:
|
38 |
-
|
39 |
except ValueError:
|
40 |
st.error("Please Enter a valid Image Address!")
|
41 |
|
42 |
if 'image' in locals(): # Check if image variable exists
|
43 |
-
st.image(
|
44 |
|
45 |
if st.button('Predict'):
|
46 |
try:
|
@@ -48,7 +48,7 @@ if 'image' in locals(): # Check if image variable exists
|
|
48 |
st.info('Worked1')
|
49 |
|
50 |
# Ensure image shape is correct and add batch dimension
|
51 |
-
img_array = preprocess(
|
52 |
|
53 |
st.info('Worked2')
|
54 |
|
|
|
29 |
if opt == 'Upload image from device':
|
30 |
file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
|
31 |
if file is not None:
|
32 |
+
image = Image.open(file).resize((256, 256), Image.LANCZOS)
|
33 |
|
34 |
|
35 |
elif opt == 'Upload image via link':
|
36 |
img_url = st.text_input('Enter the Image Address')
|
37 |
try:
|
38 |
+
image = Image.open(urllib.request.urlopen(img_url)).resize((256, 256), Image.LANCZOS)
|
39 |
except ValueError:
|
40 |
st.error("Please Enter a valid Image Address!")
|
41 |
|
42 |
if 'image' in locals(): # Check if image variable exists
|
43 |
+
st.image(image, width=300, caption='Uploaded Image')
|
44 |
|
45 |
if st.button('Predict'):
|
46 |
try:
|
|
|
48 |
st.info('Worked1')
|
49 |
|
50 |
# Ensure image shape is correct and add batch dimension
|
51 |
+
img_array = preprocess(image) # This should return an array of shape (1, 256, 256, 3)
|
52 |
|
53 |
st.info('Worked2')
|
54 |
|