Spaces:
Sleeping
Sleeping
Sergey Kolbin
commited on
Commit
·
17b68e7
1
Parent(s):
9b4c792
- .gitattributes +2 -0
- app.py +12 -0
- examples/tiger1.png +3 -0
- examples/tiger2.png +3 -0
- examples/tiger3.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
examples/*.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
examples/*.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
|
@@ -95,11 +95,22 @@ def count_big_cats(img, score_threshold, iou_threshold):
|
|
| 95 |
img_annotated = annotate(img.copy(), preds)
|
| 96 |
return tiger_count, lion_count, total_count, img_annotated
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
with gr.Blocks(title="Big Cat Counter") as demo:
|
| 99 |
gr.Markdown("# 🐯🦁 Big Cat Counter\nUpload an image and I’ll count how many **tigers** and **lions** I see.")
|
| 100 |
with gr.Row():
|
| 101 |
with gr.Column():
|
| 102 |
inp = gr.Image(type="pil", label="Input image")
|
|
|
|
| 103 |
score_th = gr.Slider(0.05, 0.95, value=0.20, step=0.05, label="Score threshold")
|
| 104 |
iou_th = gr.Slider(0.1, 0.9, value=0.50, step=0.05, label="IOU (NMS) threshold")
|
| 105 |
btn = gr.Button("Count Big Cats")
|
|
@@ -108,6 +119,7 @@ with gr.Blocks(title="Big Cat Counter") as demo:
|
|
| 108 |
out_lion = gr.Number(label="Lion count", precision=0)
|
| 109 |
out_total = gr.Number(label="Total big cats", precision=0)
|
| 110 |
out_img = gr.Image(label="Annotated output")
|
|
|
|
| 111 |
btn.click(fn=count_big_cats, inputs=[inp, score_th, iou_th], outputs=[out_tiger, out_lion, out_total, out_img])
|
| 112 |
|
| 113 |
if __name__ == "__main__":
|
|
|
|
| 95 |
img_annotated = annotate(img.copy(), preds)
|
| 96 |
return tiger_count, lion_count, total_count, img_annotated
|
| 97 |
|
| 98 |
+
TEST_IMAGES = {
|
| 99 |
+
"Tiger": "examples/tiger1.png",
|
| 100 |
+
"Lion": "examples/tiger2.png",
|
| 101 |
+
"Both": "examples/tiger3.png",
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
def load_test_image(choice):
|
| 105 |
+
return Image.open(TEST_IMAGES[choice])
|
| 106 |
+
|
| 107 |
+
|
| 108 |
with gr.Blocks(title="Big Cat Counter") as demo:
|
| 109 |
gr.Markdown("# 🐯🦁 Big Cat Counter\nUpload an image and I’ll count how many **tigers** and **lions** I see.")
|
| 110 |
with gr.Row():
|
| 111 |
with gr.Column():
|
| 112 |
inp = gr.Image(type="pil", label="Input image")
|
| 113 |
+
test_selector = gr.Dropdown(list(TEST_IMAGES.keys()), label="Pick a test image")
|
| 114 |
score_th = gr.Slider(0.05, 0.95, value=0.20, step=0.05, label="Score threshold")
|
| 115 |
iou_th = gr.Slider(0.1, 0.9, value=0.50, step=0.05, label="IOU (NMS) threshold")
|
| 116 |
btn = gr.Button("Count Big Cats")
|
|
|
|
| 119 |
out_lion = gr.Number(label="Lion count", precision=0)
|
| 120 |
out_total = gr.Number(label="Total big cats", precision=0)
|
| 121 |
out_img = gr.Image(label="Annotated output")
|
| 122 |
+
test_selector.change(fn=load_test_image, inputs=test_selector, outputs=inp)
|
| 123 |
btn.click(fn=count_big_cats, inputs=[inp, score_th, iou_th], outputs=[out_tiger, out_lion, out_total, out_img])
|
| 124 |
|
| 125 |
if __name__ == "__main__":
|
examples/tiger1.png
ADDED
|
Git LFS Details
|
examples/tiger2.png
ADDED
|
Git LFS Details
|
examples/tiger3.png
ADDED
|
Git LFS Details
|