Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
|
6 |
|
7 |
-
#
|
8 |
-
def
|
9 |
-
#
|
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 |
-
#
|
16 |
iface = gr.Interface(
|
17 |
-
fn=
|
18 |
-
inputs=
|
19 |
-
|
|
|
|
|
|
|
20 |
)
|
21 |
|
22 |
-
#
|
23 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Charger le pipeline
|
5 |
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
|
6 |
|
7 |
+
# Définir l'interface Gradio
|
8 |
+
def classify_image_with_text(text, image):
|
9 |
+
# Effectuer la classification d'image à l'aide du texte
|
10 |
+
result = pipe(image, text)
|
11 |
labels = result["labels"]
|
12 |
scores = result["scores"]
|
13 |
return {label: score for label, score in zip(labels, scores)}
|
14 |
|
15 |
+
# Créer l'interface Gradio
|
16 |
iface = gr.Interface(
|
17 |
+
fn=classify_image_with_text,
|
18 |
+
inputs=[
|
19 |
+
gr.inputs.Textbox(lines=5, label="Texte"),
|
20 |
+
gr.inputs.Image(label="Image")
|
21 |
+
],
|
22 |
+
outputs=gr.outputs.Label(num_top_classes=3) # Ajustez le nombre de classes principales si nécessaire
|
23 |
)
|
24 |
|
25 |
+
# Lancer l'interface
|
26 |
+
iface.launch()
|