Aum123 commited on
Commit
05afcd1
·
verified ·
1 Parent(s): da68fdc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -9
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
- # Create a Gradio interface
14
- gr.Interface(
15
- fn=predict,
16
- inputs=gr.Image(type="pil", label="Upload a cat image"),
17
- outputs=gr.Text(label="Predicted Breed"),
18
- title="🐱 Cat Breed Detector",
19
- description="Upload a picture of your cat to find out the breed!",
20
- theme="soft"
21
- ).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()