Spaces:
Sleeping
Sleeping
alyxx
commited on
Commit
•
c908479
1
Parent(s):
930a0be
update
Browse files- app.py +9 -33
- requirements.txt +2 -4
app.py
CHANGED
@@ -1,36 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
-
from PIL import Image
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
# Format the results to display in the interface
|
16 |
-
return {result['label']: result['score'] for result in results}
|
17 |
-
|
18 |
-
# Example Pokémon images (URLs or local file paths)
|
19 |
-
examples = [
|
20 |
-
["https://raw.githubusercontent.com/Kaiku03/Pokemon-ViT/main/examples/1.jpg"],
|
21 |
-
["https://raw.githubusercontent.com/Kaiku03/Pokemon-ViT/main/examples/2.jpg"],
|
22 |
-
["https://raw.githubusercontent.com/Kaiku03/Pokemon-ViT/main/examples/3.jpg"]
|
23 |
-
]
|
24 |
-
|
25 |
-
# Create a Gradio interface
|
26 |
-
interface = gr.Interface(
|
27 |
-
fn=classify_image,
|
28 |
-
inputs=gr.Image(type="pil"),
|
29 |
-
outputs=gr.Label(num_top_classes=3),
|
30 |
-
title="Pokémon Classification",
|
31 |
-
description="Upload a Pokémon image to classify it using this model.",
|
32 |
-
examples=examples # Add examples here
|
33 |
-
)
|
34 |
-
|
35 |
-
# Launch the interface on Hugging Face Spaces
|
36 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
+
pipe = pipeline(task="image-classification",
|
5 |
+
# model that can do 22k-category classification
|
6 |
+
model="microsoft/beit-base-patch16-224-pt22k-ft22k")
|
7 |
+
gr.Interface.from_pipeline(pipe,
|
8 |
+
title="22k Image Classification",
|
9 |
+
description="Object Recognition using Microsoft BEIT",
|
10 |
+
# examples = ['wonder_cat.jpg', 'aki_dog.jpg',],
|
11 |
+
article = "Author: <a href=\"https://huggingface.co/rowel\">Rowel Atienza</a>",
|
12 |
+
).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
requirements.txt
CHANGED
@@ -1,4 +1,2 @@
|
|
1 |
-
|
2 |
-
transformers
|
3 |
-
Pillow==9.1.0
|
4 |
-
TensorFlo==2.0
|
|
|
1 |
+
torch
|
2 |
+
transformers
|
|
|
|