create demo
Browse files- app.py +20 -0
- examples/Bengal.jpg +0 -0
- examples/Egyptian Mau.jpg +0 -0
- examples/havanese.jpg +0 -0
- examples/miniature pinscher.jpg +0 -0
- examples/scottish terrier.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
from pathlib import Path
|
4 |
+
|
5 |
+
examples = Path('./examples').glob('*')
|
6 |
+
examples = list(map(str,examples))
|
7 |
+
|
8 |
+
|
9 |
+
pipe = pipeline("image-classification", model="shreydan/vit-base-oxford-iiit-pets")
|
10 |
+
|
11 |
+
def predict(inp_path):
|
12 |
+
confidences = pipe(inp_path)
|
13 |
+
confidences = {s['label']:s['score'] for s in confidences}
|
14 |
+
return confidences
|
15 |
+
|
16 |
+
|
17 |
+
gr.Interface(fn=predict,
|
18 |
+
inputs=gr.Image(type="filepath"),
|
19 |
+
outputs=gr.Label(num_top_classes=3),
|
20 |
+
examples=examples).queue().launch()
|
examples/Bengal.jpg
ADDED
![]() |
examples/Egyptian Mau.jpg
ADDED
![]() |
examples/havanese.jpg
ADDED
![]() |
examples/miniature pinscher.jpg
ADDED
![]() |
examples/scottish terrier.jpg
ADDED
![]() |