Spaces:
Running
Running
Commit
·
495ff33
1
Parent(s):
9a738d9
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ from utils import *
|
|
8 |
|
9 |
# Initialize labels and model
|
10 |
labels = gen_labels()
|
11 |
-
st.info(print(labels))
|
12 |
model = model_arc() # Assuming this function initializes and returns a trained model
|
13 |
|
14 |
# Streamlit UI
|
@@ -31,11 +30,11 @@ opt = st.selectbox("How do you want to upload the image for classification?",
|
|
31 |
image = None
|
32 |
if opt == 'Upload image from device':
|
33 |
file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
|
34 |
-
|
35 |
if file:
|
36 |
try:
|
37 |
image = Image.open(io.BytesIO(file.read())).resize((256, 256), Image.LANCZOS)
|
38 |
-
|
39 |
except Exception as e:
|
40 |
st.error(f"Error reading the file: {e}")
|
41 |
|
@@ -60,9 +59,9 @@ try:
|
|
60 |
#model.load_weights("classify_model.h5")
|
61 |
|
62 |
|
63 |
-
|
64 |
prediction = model.predict(img[np.newaxis, ...])
|
65 |
-
|
66 |
st.info('Hey! The uploaded image has been classified as " {} waste " '.format(labels[np.argmax(prediction[0], axis=-1)]))
|
67 |
except Exception as e:
|
68 |
st.info(e)
|
|
|
8 |
|
9 |
# Initialize labels and model
|
10 |
labels = gen_labels()
|
|
|
11 |
model = model_arc() # Assuming this function initializes and returns a trained model
|
12 |
|
13 |
# Streamlit UI
|
|
|
30 |
image = None
|
31 |
if opt == 'Upload image from device':
|
32 |
file = st.file_uploader('Select', type=['jpg', 'png', 'jpeg'])
|
33 |
+
print(file)
|
34 |
if file:
|
35 |
try:
|
36 |
image = Image.open(io.BytesIO(file.read())).resize((256, 256), Image.LANCZOS)
|
37 |
+
print(image)
|
38 |
except Exception as e:
|
39 |
st.error(f"Error reading the file: {e}")
|
40 |
|
|
|
59 |
#model.load_weights("classify_model.h5")
|
60 |
|
61 |
|
62 |
+
print(model)
|
63 |
prediction = model.predict(img[np.newaxis, ...])
|
64 |
+
print(prediction)
|
65 |
st.info('Hey! The uploaded image has been classified as " {} waste " '.format(labels[np.argmax(prediction[0], axis=-1)]))
|
66 |
except Exception as e:
|
67 |
st.info(e)
|