Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ from transformers import pipeline
|
|
4 |
# Charger le pipeline
|
5 |
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
|
6 |
|
7 |
-
# Définir
|
8 |
def classify_image_with_text(text, image):
|
9 |
# Effectuer la classification d'image à l'aide du texte
|
10 |
result = pipe(image, text)
|
@@ -12,24 +12,11 @@ def classify_image_with_text(text, image):
|
|
12 |
scores = result["scores"]
|
13 |
return {label: score for label, score in zip(labels, scores)}
|
14 |
|
15 |
-
# Créer l'interface Gradio
|
16 |
-
with gr.
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
with gr.Row(scale=6):
|
24 |
-
with gr.Row():
|
25 |
-
api = gr.Button("Api", variant="primary")
|
26 |
-
with gr.Row():
|
27 |
-
api_image_output = gr.Textbox(label='Api OutPut')
|
28 |
-
|
29 |
-
|
30 |
-
api.click(classify_image_with_text, inputs=[primary_prompt,input_image], outputs=[api_image_output], api_name='generate')
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
# Lancer l'interface
|
35 |
-
iface.launch()
|
|
|
4 |
# Charger le pipeline
|
5 |
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
|
6 |
|
7 |
+
# Définir la fonction pour la classification d'image avec du texte en entrée
|
8 |
def classify_image_with_text(text, image):
|
9 |
# Effectuer la classification d'image à l'aide du texte
|
10 |
result = pipe(image, text)
|
|
|
12 |
scores = result["scores"]
|
13 |
return {label: score for label, score in zip(labels, scores)}
|
14 |
|
15 |
+
# Créer l'interface Gradio avec l'API de Gradio Blocks
|
16 |
+
with gr.Interface(
|
17 |
+
fn=classify_image_with_text,
|
18 |
+
inputs=[gr.Textbox(lines=5, label="Prompt"), gr.Image(label="Image")],
|
19 |
+
outputs=gr.Textbox(label='Sortie de l\'API'),
|
20 |
+
title="SD Models"
|
21 |
+
) as iface:
|
22 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|