Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -229,7 +229,7 @@ def classify(UserInput, Image, Textbox2, Textbox3):
|
|
229 |
print(f'Maximum Prediction: {max_label} with a value of {max_rounded_prediction}')
|
230 |
|
231 |
time.sleep(1)
|
232 |
-
if
|
233 |
print("\nWays to dispose of this waste: " + max_label)
|
234 |
messages.append({"role": "user", "content": content + " " + max_label})
|
235 |
|
@@ -246,9 +246,9 @@ def classify(UserInput, Image, Textbox2, Textbox3):
|
|
246 |
reply = response["choices"][0]["message"]["content"]
|
247 |
messages.append({"role": "assistant", "content": reply})
|
248 |
|
249 |
-
output.append({"Mode": "Image", "type": max_label, "prediction_value":
|
250 |
-
elif
|
251 |
-
output.append({"Mode": "Image", "type": "Not predictable", "prediction_value":
|
252 |
|
253 |
return output
|
254 |
|
|
|
229 |
print(f'Maximum Prediction: {max_label} with a value of {max_rounded_prediction}')
|
230 |
|
231 |
time.sleep(1)
|
232 |
+
if max_rounded_prediction > 0.5:
|
233 |
print("\nWays to dispose of this waste: " + max_label)
|
234 |
messages.append({"role": "user", "content": content + " " + max_label})
|
235 |
|
|
|
246 |
reply = response["choices"][0]["message"]["content"]
|
247 |
messages.append({"role": "assistant", "content": reply})
|
248 |
|
249 |
+
output.append({"Mode": "Image", "type": max_label, "prediction_value": max_rounded_prediction, "content": reply})
|
250 |
+
elif max_rounded_prediction < 0.5:
|
251 |
+
output.append({"Mode": "Image", "type": "Not predictable", "prediction_value": max_rounded_prediction, "content": "Seems like the prediction rate is too low due to that won't be able to predict the type of material. Try again with a cropped image or different one."})
|
252 |
|
253 |
return output
|
254 |
|