Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,23 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load the pipeline
|
5 |
+
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
|
6 |
+
|
7 |
+
# Define the Gradio interface
|
8 |
+
def classify_image(image):
|
9 |
+
# Perform zero-shot image classification
|
10 |
+
result = pipe(image)
|
11 |
+
labels = result["labels"]
|
12 |
+
scores = result["scores"]
|
13 |
+
return {label: score for label, score in zip(labels, scores)}
|
14 |
+
|
15 |
+
# Create a Gradio interface
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=classify_image,
|
18 |
+
inputs=gr.inputs.Image(),
|
19 |
+
outputs=gr.outputs.Label(num_top_classes=3) # Adjust the number of top classes as needed
|
20 |
+
)
|
21 |
+
|
22 |
+
# Launch the interface
|
23 |
+
iface.launch()
|