Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,12 +10,40 @@ def predict(image):
|
|
| 10 |
top_result = result[0]
|
| 11 |
return f"{top_result['label']} ({round(top_result['score'] * 100, 2)}%)"
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
top_result = result[0]
|
| 11 |
return f"{top_result['label']} ({round(top_result['score'] * 100, 2)}%)"
|
| 12 |
|
| 13 |
+
# All cat breeds detected by the model
|
| 14 |
+
cat_breeds = [
|
| 15 |
+
"Abyssinian", "American Bobtail", "American Curl", "American Shorthair",
|
| 16 |
+
"Applehead Siamese", "Balinese", "Bengal", "Birman", "Bombay", "British Shorthair",
|
| 17 |
+
"Burmese", "Calico", "Cornish Rex", "Devon Rex", "Dilute Calico", "Dilute Tortoiseshell",
|
| 18 |
+
"Domestic Long Hair", "Domestic Medium Hair", "Domestic Short Hair", "Egyptian Mau",
|
| 19 |
+
"Exotic Shorthair", "Extra-Toes Cat - Hemingway Polydactyl", "Havana", "Himalayan",
|
| 20 |
+
"Japanese Bobtail", "Maine Coon", "Manx", "Munchkin", "Nebelung", "Norwegian Forest",
|
| 21 |
+
"Oriental Short Hair", "Persian", "Ragamuffin", "Ragdoll", "Russian Blue",
|
| 22 |
+
"Scottish Fold", "Siamese", "Siberian", "Snowshoe", "Sphynx", "Tabby", "Tiger",
|
| 23 |
+
"Tonkinese", "Torbie", "Tortoiseshell", "Turkish Angora", "Turkish Van", "Tuxedo"
|
| 24 |
+
]
|
| 25 |
+
|
| 26 |
+
breed_list = "\n".join(cat_breeds)
|
| 27 |
+
|
| 28 |
+
# Build the UI
|
| 29 |
+
with gr.Blocks(theme="soft") as demo:
|
| 30 |
+
gr.Markdown("""
|
| 31 |
+
# 🐾 Cat Breed Detector
|
| 32 |
+
Upload a picture of your cat, and let AI tell you its breed!
|
| 33 |
+
Powered by 🤗 Hugging Face Transformers and a custom fine-tuned model.
|
| 34 |
+
""")
|
| 35 |
+
|
| 36 |
+
with gr.Row(equal_height=True):
|
| 37 |
+
with gr.Column(scale=1):
|
| 38 |
+
image_input = gr.Image(type="pil", label="📸 Upload a Cat Image", shape=(300, 300))
|
| 39 |
+
output = gr.Textbox(label="🎯 Predicted Breed", interactive=False)
|
| 40 |
+
with gr.Column(scale=1):
|
| 41 |
+
gr.Markdown("### 🐱 All Supported Cat Breeds")
|
| 42 |
+
gr.Textbox(value=breed_list, label="", lines=25, interactive=False, max_lines=25, show_copy_button=True)
|
| 43 |
+
|
| 44 |
+
gr.Markdown("---")
|
| 45 |
+
gr.Markdown("Made with ❤️ by Sumon Banerjee • Model: `dima806/cat_breed_image_detection`")
|
| 46 |
+
|
| 47 |
+
image_input.change(fn=predict, inputs=image_input, outputs=output)
|
| 48 |
+
|
| 49 |
+
demo.launch()
|