Spaces:
Running
Running
File size: 833 Bytes
05be9b2 d083901 05be9b2 35ceb6f d083901 f2b5de1 10e52d2 35ceb6f d083901 f2b5de1 10e52d2 d083901 10e52d2 |
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 |
import gradio as gr
from transformers import AutoProcessor, CLIPModel
# Charger le pipeline
model = CLIPModel.from_pretrained("patrickjohncyh/fashion-clip")
processor = AutoProcessor.from_pretrained("patrickjohncyh/fashion-clip")
# Définir la fonction pour la classification d'image avec du texte en entrée
def classify_image_with_text(text, image):
# Effectuer la classification d'image à l'aide du texte
inputs = processor(
text=[text], images=image, return_tensors="pt", padding=True
)
return model(**inputs)
# Créer l'interface Gradio avec l'API de Gradio Blocks
with gr.Interface(
fn=classify_image_with_text,
inputs=[gr.Textbox(lines=1, label="Prompt"), gr.Image(label="Image")],
outputs=gr.Textbox(label='Sortie de l\'API'),
title="SD Models"
) as iface:
iface.launch()
|