Spaces:
Runtime error
Runtime error
Try model
Browse files
app.py
CHANGED
|
@@ -1,16 +1,12 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
"""
|
| 4 |
-
pipe = pipeline("classification", model="openai/clip-vit-large-patch14")
|
| 5 |
def classify(img):
|
| 6 |
-
predictions =
|
| 7 |
-
pipe(text=["", "a photo of a dog"], images=image, return_tensors="pt", padding=True)
|
| 8 |
return predictions
|
| 9 |
|
| 10 |
iface = gr.Interface(fn=classify, inputs="image", outputs="text")
|
| 11 |
-
iface.launch()
|
| 12 |
-
"""
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
iface = gr.load("huggingface/openai/clip-vit-large-patch14")
|
| 16 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
checkpoint = "openai/clip-vit-large-patch14"
|
| 5 |
+
detector = pipeline(model=checkpoint, task="zero-shot-image-classification")
|
| 6 |
|
|
|
|
|
|
|
| 7 |
def classify(img):
|
| 8 |
+
predictions = detector(img, candidate_labels=["fox", "bear", "seagull", "owl"])
|
|
|
|
| 9 |
return predictions
|
| 10 |
|
| 11 |
iface = gr.Interface(fn=classify, inputs="image", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
iface.launch()
|