File size: 1,140 Bytes
05be9b2
f2b5de1
05be9b2
35ceb6f
f2b5de1
 
35ceb6f
 
 
 
f2b5de1
 
 
 
35ceb6f
373c79f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2b5de1
35ceb6f
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from transformers import pipeline

# Charger le pipeline
pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")

# Définir l'interface Gradio
def classify_image_with_text(text, image):
    # Effectuer la classification d'image à l'aide du texte
    result = pipe(image, text)
    labels = result["labels"]
    scores = result["scores"]
    return {label: score for label, score in zip(labels, scores)}

# Créer l'interface Gradio
with gr.Blocks(title="SD Models") as my_interface:
    with gr.Column(scale=12):
        with gr.Row():
            with gr.Row(scale=6):
                primary_prompt = gr.Textbox(label="Prompt", value="")
                input_image = gr.Image(label="Image")

            with gr.Row(scale=6):
                with gr.Row():
                    api = gr.Button("Api", variant="primary")
        with gr.Row():
            api_image_output = gr.Textbox(label='Api OutPut')
         

        api.click(classify_image_with_text, inputs=[primary_prompt,input_image], outputs=[api_image_output], api_name='generate')



# Lancer l'interface
iface.launch()