Spaces:
Runtime error
Runtime error
Commit
·
7e08656
1
Parent(s):
49c55dc
fix app
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import AutoModelForVision2Seq, AutoProcessor,
|
| 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 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|