Spaces:
Sleeping
Sleeping
bsvaz
commited on
Commit
·
03407d2
1
Parent(s):
267229f
first commit
Browse files- app.py +22 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load your model from the Hugging Face Hub
|
5 |
+
model_name = "bsvaz/landmark-classification-vit" # Replace with your model's path on the Hub
|
6 |
+
classifier = pipeline("image-classification", model=model_name)
|
7 |
+
|
8 |
+
# Define the prediction function
|
9 |
+
def classify_image(image):
|
10 |
+
results = classifier(image)
|
11 |
+
return {result["label"]: result["score"] for result in results}
|
12 |
+
|
13 |
+
# Create a Gradio interface
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=classify_image,
|
16 |
+
inputs=gr.Image(type="pil"),
|
17 |
+
outputs="label",
|
18 |
+
title="Image Classification",
|
19 |
+
description="Upload an image to classify it."
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
gradio
|
3 |
+
torch
|