Abhishek Gola
commited on
Commit
·
4712951
1
Parent(s):
de320a0
Added samples
Browse files- .gitattributes +5 -0
- app.py +38 -9
- examples/baboon.jpg +3 -0
- examples/squirrel_cls.jpg +3 -0
.gitattributes
CHANGED
@@ -14,6 +14,11 @@
|
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
17 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
|
|
14 |
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.webp filter=lfs diff=lfs merge=lfs -te
|
22 |
*.ot filter=lfs diff=lfs merge=lfs -text
|
23 |
*.parquet filter=lfs diff=lfs merge=lfs -text
|
24 |
*.pb filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -22,15 +22,44 @@ def classify_image(input_image):
|
|
22 |
result_str = "\n".join(f"{label}" for label in result)
|
23 |
return result_str
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
demo.launch()
|
|
|
22 |
result_str = "\n".join(f"{label}" for label in result)
|
23 |
return result_str
|
24 |
|
25 |
+
def clear_output_on_change(img):
|
26 |
+
return gr.update(value="")
|
27 |
+
|
28 |
+
def clear_all():
|
29 |
+
return None, None
|
30 |
+
|
31 |
+
with gr.Blocks(css='''.example * {
|
32 |
+
font-style: italic;
|
33 |
+
font-size: 18px !important;
|
34 |
+
color: #0ea5e9 !important;
|
35 |
+
}''') as demo:
|
36 |
+
|
37 |
+
gr.Markdown("### Image Classification with MobileNet (OpenCV DNN)")
|
38 |
+
gr.Markdown("Upload an image to classify using a MobileNet model loaded with OpenCV DNN.")
|
39 |
+
|
40 |
+
with gr.Row():
|
41 |
+
image_input = gr.Image(type="numpy", label="Upload Image")
|
42 |
+
output_box = gr.Textbox(label="Top Prediction(s)")
|
43 |
+
|
44 |
+
# Clear output when new image is uploaded
|
45 |
+
image_input.change(fn=clear_output_on_change, inputs=image_input, outputs=output_box)
|
46 |
+
|
47 |
+
with gr.Row():
|
48 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
49 |
+
clear_btn = gr.Button("Clear")
|
50 |
+
|
51 |
+
submit_btn.click(fn=classify_image, inputs=image_input, outputs=output_box)
|
52 |
+
clear_btn.click(fn=clear_all, outputs=[image_input, output_box])
|
53 |
+
|
54 |
+
gr.Markdown("Click on any example to try it.", elem_classes=["example"])
|
55 |
+
|
56 |
+
gr.Examples(
|
57 |
+
examples=[
|
58 |
+
["examples/squirrel_cls.jpg"],
|
59 |
+
["examples/baboon.jpg"]
|
60 |
+
],
|
61 |
+
inputs=image_input
|
62 |
+
)
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
demo.launch()
|
examples/baboon.jpg
ADDED
![]() |
Git LFS Details
|
examples/squirrel_cls.jpg
ADDED
![]() |
Git LFS Details
|