Saad0KH commited on
Commit
35ceb6f
·
verified ·
1 Parent(s): cba69cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -1,23 +1,26 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load the pipeline
5
  pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
6
 
7
- # Define the Gradio interface
8
- def classify_image(image):
9
- # Perform zero-shot image classification
10
- result = pipe(image)
11
  labels = result["labels"]
12
  scores = result["scores"]
13
  return {label: score for label, score in zip(labels, scores)}
14
 
15
- # Create a Gradio interface
16
  iface = gr.Interface(
17
- fn=classify_image,
18
- inputs=gr.inputs.Image(),
19
- outputs=gr.outputs.Label(num_top_classes=3) # Adjust the number of top classes as needed
 
 
 
20
  )
21
 
22
- # Launch the interface
23
- iface.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Charger le pipeline
5
  pipe = pipeline("zero-shot-image-classification", model="patrickjohncyh/fashion-clip")
6
 
7
+ # Définir l'interface Gradio
8
+ def classify_image_with_text(text, image):
9
+ # Effectuer la classification d'image à l'aide du texte
10
+ result = pipe(image, text)
11
  labels = result["labels"]
12
  scores = result["scores"]
13
  return {label: score for label, score in zip(labels, scores)}
14
 
15
+ # Créer l'interface Gradio
16
  iface = gr.Interface(
17
+ fn=classify_image_with_text,
18
+ inputs=[
19
+ gr.inputs.Textbox(lines=5, label="Texte"),
20
+ gr.inputs.Image(label="Image")
21
+ ],
22
+ outputs=gr.outputs.Label(num_top_classes=3) # Ajustez le nombre de classes principales si nécessaire
23
  )
24
 
25
+ # Lancer l'interface
26
+ iface.launch()