fohy24 commited on
Commit ·
f7724ab
1
Parent(s): e25cd6e
update layout from gr.interface to gr.blocks; add accordion to show prediction labels
Browse files
app.py
CHANGED
|
@@ -82,13 +82,35 @@ def predict(img, confidence):
|
|
| 82 |
return prediction_dict
|
| 83 |
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
-
|
| 87 |
-
inputs=[gr.Image(type="pil"),
|
| 88 |
-
gr.Slider(0, 1, value=0.5, label="Confidence", info="Show predictions that are above this confidence level")],
|
| 89 |
-
outputs=gr.Label(),
|
| 90 |
-
examples=[["enchi_albino_clown.png", 0.5], ["mojave_ghi.png", 0.5], ["hypo_banana_pastel_enchi.png", 0.5]],
|
| 91 |
-
title='Ball Python Morph Identifier',
|
| 92 |
-
description="Upload or paste an image of your ball python to identify its morphs!"
|
| 93 |
-
).launch()
|
| 94 |
|
|
|
|
| 82 |
return prediction_dict
|
| 83 |
|
| 84 |
|
| 85 |
+
with gr.Blocks(title='Ball Python Morph Identifier') as demo:
|
| 86 |
+
gr.Markdown("# Ball Python Morph Identifier")
|
| 87 |
+
gr.Markdown("Upload or paste an image of your ball python to identify its morphs!")
|
| 88 |
+
|
| 89 |
+
with gr.Accordion("Click here to show all the morphs that can be predicted", open=False):
|
| 90 |
+
gr.Markdown("""
|
| 91 |
+
Albino, Asphalt, Banana, Black Head, Black Pastel, Butter, Calico, Chocolate, Cinnamon, Clown, Desert Ghost, Enchi, Fire,
|
| 92 |
+
GHI, Gravel, Hypo, Leopard, Lesser, Mojave, Normal, Orange Dream, Pastel, Piebald, Pinstripe, Red Stripe,
|
| 93 |
+
Spider, Spotnose, Super Pastel, Vanilla, Yellow Belly
|
| 94 |
+
""")
|
| 95 |
+
|
| 96 |
+
with gr.Row():
|
| 97 |
+
with gr.Column(scale=1):
|
| 98 |
+
img_input = gr.Image(type="pil", label="Upload/Paste Image")
|
| 99 |
+
gr.Examples(
|
| 100 |
+
examples=[
|
| 101 |
+
["enchi_albino_clown.png", "Enchi, Albino, Clown"],
|
| 102 |
+
["mojave_ghi.png", "Mojave, GHI"],
|
| 103 |
+
["hypo_banana_pastel_enchi.png", "Hypo, Banana, Pastel, Enchi"]],
|
| 104 |
+
inputs=[img_input]
|
| 105 |
+
)
|
| 106 |
+
confidence = gr.Slider(0, 1, value=0.5, label="Confidence",
|
| 107 |
+
info="Show predictions that are above this confidence level")
|
| 108 |
+
predict_btn = gr.Button("Identify Morphs", variant="primary")
|
| 109 |
+
|
| 110 |
+
with gr.Column(scale=1):
|
| 111 |
+
label_output = gr.Label(label="Predicted Morphs")
|
| 112 |
+
|
| 113 |
+
predict_btn.click(fn=predict, inputs=[img_input, confidence], outputs=label_output)
|
| 114 |
|
| 115 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|