Spaces:
Runtime error
Runtime error
SerenaTOUM
commited on
Commit
•
9703332
1
Parent(s):
fc54c8e
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
classification = pipeline ("zero-shot-image-classification", model ="openai/clip-vit-large-patch14")
|
3 |
+
|
4 |
+
import gradio as gr
|
5 |
+
def classify_image(image):
|
6 |
+
labels = ["groupe1", "groupe2", "groupe3"]
|
7 |
+
classification = classification(image, labels)
|
8 |
+
return classification
|
9 |
+
image_input = gr.Image()
|
10 |
+
label_output = gr.Label(num_top_classes=3)
|
11 |
+
|
12 |
+
gr.Interface(fn=classify_image, inputs=image_input, outputs=label_output,
|
13 |
+
title="Zero-Shot Image Classification",
|
14 |
+
description="Classify images into predefined classes without fine-tuning the model.",
|
15 |
+
allow_flagging=False).launch()
|