amadinahmed
commited on
Commit
·
c7a1e36
1
Parent(s):
4b77d63
adaadda
Browse files
app.py
CHANGED
@@ -77,8 +77,6 @@ def predict_image(inp):
|
|
77 |
"""
|
78 |
Performs inference for a given input image and returns the prediction and CAM image.
|
79 |
"""
|
80 |
-
|
81 |
-
|
82 |
material_label, material_label_idx, material_probs = materials_model.predict(inp)
|
83 |
material_preds = {name: prob for name, prob in zip(material_names, material_probs.tolist())}
|
84 |
|
@@ -119,6 +117,7 @@ def predict_image(inp):
|
|
119 |
|
120 |
return material_preds, specific_preds, recyclable_qn, recyclable_advice
|
121 |
|
|
|
122 |
css = """
|
123 |
#warning {background-color: #FFCCCB}
|
124 |
#custom_header {min-height: 3rem} #custom_title {min-height: 3rem; text-align: center}
|
@@ -141,10 +140,12 @@ with gr.Blocks(title="Trash Classification", css=css) as demo:
|
|
141 |
gr.Markdown("### Can it Recycle?")
|
142 |
recycling_advice = gr.outputs.Label()
|
143 |
gr.Markdown("### How to recycle?")
|
144 |
-
|
|
|
|
|
145 |
|
146 |
|
147 |
-
btn.click(predict_image, inputs=[input_image],
|
148 |
-
outputs=[item_probs, recycling_qn, recycling_advice])
|
149 |
if __name__ == "__main__":
|
150 |
demo.launch()
|
|
|
77 |
"""
|
78 |
Performs inference for a given input image and returns the prediction and CAM image.
|
79 |
"""
|
|
|
|
|
80 |
material_label, material_label_idx, material_probs = materials_model.predict(inp)
|
81 |
material_preds = {name: prob for name, prob in zip(material_names, material_probs.tolist())}
|
82 |
|
|
|
117 |
|
118 |
return material_preds, specific_preds, recyclable_qn, recyclable_advice
|
119 |
|
120 |
+
|
121 |
css = """
|
122 |
#warning {background-color: #FFCCCB}
|
123 |
#custom_header {min-height: 3rem} #custom_title {min-height: 3rem; text-align: center}
|
|
|
140 |
gr.Markdown("### Can it Recycle?")
|
141 |
recycling_advice = gr.outputs.Label()
|
142 |
gr.Markdown("### How to recycle?")
|
143 |
+
with gr.Row():
|
144 |
+
material_probs = gr.outputs.Label(label="Material Prediction")
|
145 |
+
item_probs = gr.outputs.Label(label="Item Prediction")
|
146 |
|
147 |
|
148 |
+
btn.click(predict_image, inputs=[input_image],
|
149 |
+
outputs=[material_probs, item_probs, recycling_qn, recycling_advice])
|
150 |
if __name__ == "__main__":
|
151 |
demo.launch()
|