Spaces:
Running
Running
Commit
·
329853e
1
Parent(s):
581f508
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,7 +25,7 @@ if mode == "Predict Mode":
|
|
| 25 |
st.header("Upload a waste image to find its category")
|
| 26 |
|
| 27 |
# Note
|
| 28 |
-
st.markdown("* Please note that our dataset is trained primarily with images that contain a white background.
|
| 29 |
|
| 30 |
# Image upload section
|
| 31 |
opt = st.selectbox("How do you want to upload the image for classification?", ("Please Select", "Upload image from device"))
|
|
@@ -38,7 +38,7 @@ if mode == "Predict Mode":
|
|
| 38 |
try:
|
| 39 |
image = preprocess_image(file)
|
| 40 |
except Exception as e:
|
| 41 |
-
st.error(f"An error occurred: {e}.
|
| 42 |
try:
|
| 43 |
if image is not None:
|
| 44 |
st.image(image, width=256, caption='Uploaded Image')
|
|
@@ -53,14 +53,10 @@ if mode == "Predict Mode":
|
|
| 53 |
# Allow user to provide correct label
|
| 54 |
user_label = st.text_input("Enter the correct label:")
|
| 55 |
if user_label:
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
target = np.zeros(len(labels))
|
| 59 |
-
target[labels.index(user_label)] = 1
|
| 60 |
-
model.train_on_batch(image[np.newaxis, ...], target)
|
| 61 |
-
st.success(f'Thank you for providing feedback. Model has been updated with the new label.')
|
| 62 |
except Exception as e:
|
| 63 |
-
st.error(f"An error occurred: {e}.
|
| 64 |
|
| 65 |
elif mode == "Train Mode":
|
| 66 |
# Train the model with a new image and label
|
|
@@ -84,4 +80,4 @@ elif mode == "Train Mode":
|
|
| 84 |
model.train_on_batch(image[np.newaxis, ...], target)
|
| 85 |
st.success(f'Model has been trained with the new image and label.')
|
| 86 |
except Exception as e:
|
| 87 |
-
st.error(f"An error occurred: {e}.
|
|
|
|
| 25 |
st.header("Upload a waste image to find its category")
|
| 26 |
|
| 27 |
# Note
|
| 28 |
+
st.markdown("* Please note that our dataset is trained primarily with images that contain a white background. Therefore, images with a white background would produce maximum accuracy *")
|
| 29 |
|
| 30 |
# Image upload section
|
| 31 |
opt = st.selectbox("How do you want to upload the image for classification?", ("Please Select", "Upload image from device"))
|
|
|
|
| 38 |
try:
|
| 39 |
image = preprocess_image(file)
|
| 40 |
except Exception as e:
|
| 41 |
+
st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")
|
| 42 |
try:
|
| 43 |
if image is not None:
|
| 44 |
st.image(image, width=256, caption='Uploaded Image')
|
|
|
|
| 53 |
# Allow user to provide correct label
|
| 54 |
user_label = st.text_input("Enter the correct label:")
|
| 55 |
if user_label:
|
| 56 |
+
st.success(f'Thank you for providing feedback. Please switch to "Train Mode" to update the model.')
|
| 57 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
except Exception as e:
|
| 59 |
+
st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")
|
| 60 |
|
| 61 |
elif mode == "Train Mode":
|
| 62 |
# Train the model with a new image and label
|
|
|
|
| 80 |
model.train_on_batch(image[np.newaxis, ...], target)
|
| 81 |
st.success(f'Model has been trained with the new image and label.')
|
| 82 |
except Exception as e:
|
| 83 |
+
st.error(f"An error occurred: {e}. Please contact us EcoClim Solutions at EcoClimSolutions.wordpress.com.")
|