qgallouedec HF Staff commited on
Commit
7e08656
·
1 Parent(s): 49c55dc
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -1,5 +1,5 @@
1
  import gradio as gr
2
- from transformers import AutoModelForVision2Seq, AutoProcessor, AutoModelForVision2Seq, BitsAndBytesConfig
3
  import torch
4
 
5
 
@@ -30,9 +30,15 @@ def respond(multimodal_input):
30
  generated_text = processor.batch_decode(new_tokens, skip_special_tokens=True)[0]
31
  return generated_text
32
 
33
- title = "IDEFICS2-8B DPO"
34
- description = "Try IDEFICS2-8B fine-tuned using direct preference optimization (DPO) in this demo. Learn more about vision language model DPO integration of TRL [here]."
35
- examples=[{"text": "What is the type of flower in the image and what insect is on it?", "files": ["./bee.jpg"]},
36
- {"text": "Describe the image", "files": ["./howl.jpg"]}],
37
- gr.Interface(respond, inputs=[gr.MultimodalTextbox(file_types=["image"], show_label=False)], outputs="text",
38
- title=title, description=description, examples=examples).launch()
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from transformers import AutoModelForVision2Seq, AutoProcessor, BitsAndBytesConfig
3
  import torch
4
 
5
 
 
30
  generated_text = processor.batch_decode(new_tokens, skip_special_tokens=True)[0]
31
  return generated_text
32
 
33
+
34
+ gr.Interface(
35
+ respond,
36
+ inputs=[gr.MultimodalTextbox(file_types=["image"], show_label=False)],
37
+ outputs="text",
38
+ title="IDEFICS2-8B DPO",
39
+ description="Try IDEFICS2-8B fine-tuned using direct preference optimization (DPO) in this demo. Learn more about vision language model DPO integration of TRL [here](https://huggingface.co/blog/dpo_vlm).",
40
+ examples=[
41
+ {"text": "What is the type of flower in the image and what insect is on it?", "files": ["./bee.jpg"]},
42
+ {"text": "Describe the image", "files": ["./howl.jpg"]},
43
+ ],
44
+ ).launch()