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()