Spaces:
Sleeping
Sleeping
Commit ·
902a329
1
Parent(s): e2229d2
Model prompt change
Browse files
app.py
CHANGED
|
@@ -211,15 +211,16 @@ def classify_pipeline(image):
|
|
| 211 |
top_label = max(predictions, key=predictions.get) # top-1
|
| 212 |
return predictions
|
| 213 |
|
| 214 |
-
def analyze_pipeline(
|
| 215 |
global top_label
|
| 216 |
|
| 217 |
if top_label is None:
|
| 218 |
return "Please classify an image first."
|
| 219 |
|
| 220 |
explanation = explain_recycling(top_label)
|
| 221 |
-
|
| 222 |
-
|
|
|
|
| 223 |
result = (
|
| 224 |
f"• Recycling type: {info['Recycling type']}\n"
|
| 225 |
f"• Disposal: {info['Disposal']}\n"
|
|
@@ -340,7 +341,7 @@ with gr.Blocks() as demo:
|
|
| 340 |
|
| 341 |
analyze_result_btn.click(
|
| 342 |
analyze_pipeline,
|
| 343 |
-
inputs=
|
| 344 |
outputs=explain_output
|
| 345 |
)
|
| 346 |
|
|
|
|
| 211 |
top_label = max(predictions, key=predictions.get) # top-1
|
| 212 |
return predictions
|
| 213 |
|
| 214 |
+
def analyze_pipeline():
|
| 215 |
global top_label
|
| 216 |
|
| 217 |
if top_label is None:
|
| 218 |
return "Please classify an image first."
|
| 219 |
|
| 220 |
explanation = explain_recycling(top_label)
|
| 221 |
+
|
| 222 |
+
choice = random.randint(0, 2)
|
| 223 |
+
info = analysis[choice][top_label]
|
| 224 |
result = (
|
| 225 |
f"• Recycling type: {info['Recycling type']}\n"
|
| 226 |
f"• Disposal: {info['Disposal']}\n"
|
|
|
|
| 341 |
|
| 342 |
analyze_result_btn.click(
|
| 343 |
analyze_pipeline,
|
| 344 |
+
inputs=None,
|
| 345 |
outputs=explain_output
|
| 346 |
)
|
| 347 |
|