Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
# Use a pipeline as a high-level helper
|
| 4 |
+
from transformers import pipeline
|
| 5 |
+
|
| 6 |
+
pipe = pipeline("zero-shot-image-classification", model="openai/clip-vit-large-patch14")
|
| 7 |
+
def classify_image(image):
|
| 8 |
+
result = pipe(image, ["cat", "dog", "car", "person", "building"])
|
| 9 |
+
return result
|
| 10 |
+
|
| 11 |
+
demo = gr.Interface(fn=classify_image, inputs=gr.Image(type="pil"), outputs="json")
|
| 12 |
+
|
| 13 |
+
demo.launch()
|