Spaces:
Sleeping
Sleeping
Commit ·
16eda98
1
Parent(s): 33529f1
prompt model change
Browse files
app.py
CHANGED
|
@@ -41,45 +41,36 @@ chat_model = T5ForConditionalGeneration.from_pretrained("google/flan-t5-base")
|
|
| 41 |
def explain_recycling(class_label):
|
| 42 |
prompt = f"""
|
| 43 |
Example 1:
|
| 44 |
-
• Recycling type: Glass
|
| 45 |
-
• Disposal: Rinse and
|
| 46 |
-
• Processing: Crushed into cullet and remelted
|
| 47 |
-
• Tip: Reuse bottles for storage
|
| 48 |
|
| 49 |
Example 2:
|
| 50 |
-
• Recycling type: Paper
|
| 51 |
-
• Disposal:
|
| 52 |
-
• Processing: Pulped and formed into new paper
|
| 53 |
-
• Tip: Use both sides before discarding
|
| 54 |
|
| 55 |
Example 3:
|
| 56 |
-
• Recycling type: Cardboard
|
| 57 |
-
• Disposal: Flatten and
|
| 58 |
-
• Processing: Pulped and remade into cardboard sheets
|
| 59 |
-
• Tip: Reuse boxes for storage
|
| 60 |
|
| 61 |
Example 4:
|
| 62 |
-
• Recycling type: Plastic
|
| 63 |
-
• Disposal:
|
| 64 |
-
• Processing: Shredded and melted into pellets
|
| 65 |
-
• Tip: Use refillable bottles
|
| 66 |
|
| 67 |
Example 5:
|
| 68 |
-
|
| 69 |
-
•
|
| 70 |
-
• Disposal: Rinse and place in metal recycling
|
| 71 |
-
• Processing: Melted and recast into new cans
|
| 72 |
-
• Tip: Crush cans to save space
|
| 73 |
|
| 74 |
Example 6:
|
| 75 |
-
|
| 76 |
-
•
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
"""
|
| 84 |
|
| 85 |
inputs = tokenizer(prompt, return_tensors="pt").input_ids
|
|
@@ -112,7 +103,7 @@ with gr.Blocks() as demo:
|
|
| 112 |
explain_output = gr.Textbox(
|
| 113 |
label="Detailed Recycling & Disposal Advice",
|
| 114 |
elem_id="explainbox",
|
| 115 |
-
lines=
|
| 116 |
)
|
| 117 |
|
| 118 |
analyze_btn = gr.Button("Analyze", variant="primary")
|
|
|
|
| 41 |
def explain_recycling(class_label):
|
| 42 |
prompt = f"""
|
| 43 |
Example 1:
|
| 44 |
+
• Recycling type: Glass\n
|
| 45 |
+
• Disposal: Rinse and put in the municipal glass-only bin\n
|
|
|
|
|
|
|
| 46 |
|
| 47 |
Example 2:
|
| 48 |
+
• Recycling type: Paper\n
|
| 49 |
+
• Disposal: Place in the clean paper recycling stream\n
|
|
|
|
|
|
|
| 50 |
|
| 51 |
Example 3:
|
| 52 |
+
• Recycling type: Cardboard\n
|
| 53 |
+
• Disposal: Flatten and place in the cardboard/boxboard bin\n
|
|
|
|
|
|
|
| 54 |
|
| 55 |
Example 4:
|
| 56 |
+
• Recycling type: Plastic (#1–#2 typically)\n
|
| 57 |
+
• Disposal: Empty and place in your plastics recycling bin\n
|
|
|
|
|
|
|
| 58 |
|
| 59 |
Example 5:
|
| 60 |
+
• Recycling type: Metal (aluminum)\n
|
| 61 |
+
• Disposal: Rinse and place in the municipal metal/aluminum bin\n
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
Example 6:
|
| 64 |
+
• Recycling type: Trash (non-recyclable)\n
|
| 65 |
+
• Disposal: Put in general landfill waste bin\n
|
| 66 |
+
|
| 67 |
+
Now answer in the exact same 2-bullet format using these rules:
|
| 68 |
+
- ALWAYS include "\n" at the end of every bullet.
|
| 69 |
+
- ALWAYS produce exactly 2 bullets.
|
| 70 |
+
- DO NOT merge lines.
|
| 71 |
+
- Keep it short.
|
| 72 |
+
|
| 73 |
+
Item: {class_label}
|
| 74 |
"""
|
| 75 |
|
| 76 |
inputs = tokenizer(prompt, return_tensors="pt").input_ids
|
|
|
|
| 103 |
explain_output = gr.Textbox(
|
| 104 |
label="Detailed Recycling & Disposal Advice",
|
| 105 |
elem_id="explainbox",
|
| 106 |
+
lines=4
|
| 107 |
)
|
| 108 |
|
| 109 |
analyze_btn = gr.Button("Analyze", variant="primary")
|