amadinahmed
commited on
Commit
·
b032c69
1
Parent(s):
f88d5c1
fafafafafa
Browse files
app.py
CHANGED
@@ -77,6 +77,7 @@ def predict_image(inp):
|
|
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 |
|
@@ -127,7 +128,7 @@ with gr.Blocks(title="Trash Classification", css=css) as demo:
|
|
127 |
|
128 |
with gr.Column():
|
129 |
with gr.Row():
|
130 |
-
item_probs = gr.outputs.Label(num_top_classes=1)
|
131 |
with gr.Column():
|
132 |
gr.Markdown("## Inputs", elem_id="custom_header")
|
133 |
input_image = gr.Image(label="Input Image")
|
@@ -140,6 +141,8 @@ with gr.Blocks(title="Trash Classification", css=css) as demo:
|
|
140 |
recycling_advice = gr.outputs.Label()
|
141 |
gr.Markdown("### How to recycle?")
|
142 |
recycling_qn = gr.outputs.Label()
|
|
|
|
|
143 |
|
144 |
|
145 |
|
@@ -150,7 +153,7 @@ with gr.Blocks(title="Trash Classification", css=css) as demo:
|
|
150 |
cache_examples=False,
|
151 |
)
|
152 |
|
153 |
-
btn.click(predict_image, inputs=[input_image],
|
154 |
outputs=[item_probs, recycling_qn, recycling_advice])
|
155 |
if __name__ == "__main__":
|
156 |
demo.launch()
|
|
|
77 |
"""
|
78 |
Performs inference for a given input image and returns the prediction and CAM image.
|
79 |
"""
|
80 |
+
|
81 |
material_label, material_label_idx, material_probs = materials_model.predict(inp)
|
82 |
material_preds = {name: prob for name, prob in zip(material_names, material_probs.tolist())}
|
83 |
|
|
|
128 |
|
129 |
with gr.Column():
|
130 |
with gr.Row():
|
131 |
+
item_probs = gr.outputs.Label(num_top_classes=1,visible=False)
|
132 |
with gr.Column():
|
133 |
gr.Markdown("## Inputs", elem_id="custom_header")
|
134 |
input_image = gr.Image(label="Input Image")
|
|
|
141 |
recycling_advice = gr.outputs.Label()
|
142 |
gr.Markdown("### How to recycle?")
|
143 |
recycling_qn = gr.outputs.Label()
|
144 |
+
def submit_visible():
|
145 |
+
return {item_probs: gr.outputs.Label(num_top_classes=1, visible=True)}
|
146 |
|
147 |
|
148 |
|
|
|
153 |
cache_examples=False,
|
154 |
)
|
155 |
|
156 |
+
btn.click(predict_image, submit_visible, inputs=[input_image],
|
157 |
outputs=[item_probs, recycling_qn, recycling_advice])
|
158 |
if __name__ == "__main__":
|
159 |
demo.launch()
|