Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -11,12 +11,13 @@ processor = AutoProcessor.from_pretrained("patrickjohncyh/fashion-clip")
|
|
11 |
def classify_image_with_text(text, image):
|
12 |
# Effectuer la classification d'image à l'aide du texte
|
13 |
inputs = processor(
|
14 |
-
text=
|
15 |
)
|
16 |
outputs = model(**inputs)
|
17 |
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
|
18 |
probs = logits_per_image.softmax(dim=1)
|
19 |
predicted_class_index = probs.argmax(dim=1).item()
|
|
|
20 |
return predicted_class_index
|
21 |
|
22 |
# Créer l'interface Gradio avec l'API de Gradio Blocks
|
|
|
11 |
def classify_image_with_text(text, image):
|
12 |
# Effectuer la classification d'image à l'aide du texte
|
13 |
inputs = processor(
|
14 |
+
text=text, images=image, return_tensors="pt", padding=True
|
15 |
)
|
16 |
outputs = model(**inputs)
|
17 |
logits_per_image = outputs.logits_per_image # this is the image-text similarity score
|
18 |
probs = logits_per_image.softmax(dim=1)
|
19 |
predicted_class_index = probs.argmax(dim=1).item()
|
20 |
+
predicted_label = text[predicted_class_index]
|
21 |
return predicted_class_index
|
22 |
|
23 |
# Créer l'interface Gradio avec l'API de Gradio Blocks
|