Spaces:
Runtime error
Runtime error
Rename app_24_4_2024.py to app.py
Browse files
app_24_4_2024.py → app.py
RENAMED
|
@@ -12,14 +12,14 @@ USE_LORA = False
|
|
| 12 |
USE_QLORA = True
|
| 13 |
|
| 14 |
processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics2-8b", do_image_splitting=False)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
|
| 22 |
-
model = Idefics2ForConditionalGeneration.from_pretrained("HuggingFaceM4/idefics2-8b",load_in_4bit=True)
|
| 23 |
|
| 24 |
# if USE_QLORA or USE_LORA:
|
| 25 |
# lora_config = LoraConfig(
|
|
@@ -76,14 +76,14 @@ def model_inference(image, text):
|
|
| 76 |
# submit_btn = gr.Button("Generate")
|
| 77 |
# output = gr.Textbox(label="Model Output")
|
| 78 |
|
| 79 |
-
with gr.Blocks(css="
|
| 80 |
-
gr.Markdown("##
|
| 81 |
with gr.Row():
|
| 82 |
with gr.Column(scale=1):
|
| 83 |
image_input = gr.Image(label="Upload Image", type="pil", tool="editor", height=480, width=640)
|
| 84 |
query_input = gr.Textbox(label="Enter Prompt", placeholder="Type your prompt here...")
|
| 85 |
with gr.Column(scale=1):
|
| 86 |
-
output = gr.Textbox(label="Model Output", interactive=True, placeholder="Output will be displayed here...")
|
| 87 |
|
| 88 |
submit_btn = gr.Button("Generate")
|
| 89 |
submit_btn.click(model_inference, inputs=[image_input, query_input], outputs=output)
|
|
|
|
| 12 |
USE_QLORA = True
|
| 13 |
|
| 14 |
processor = AutoProcessor.from_pretrained("HuggingFaceM4/idefics2-8b", do_image_splitting=False)
|
| 15 |
+
bnb_config = BitsAndBytesConfig(
|
| 16 |
+
load_in_4bit=True,
|
| 17 |
+
bnb_4bit_quant_type="nf4",
|
| 18 |
+
bnb_4bit_compute_dtype=torch.float16
|
| 19 |
+
)
|
| 20 |
|
| 21 |
|
| 22 |
+
model = Idefics2ForConditionalGeneration.from_pretrained("HuggingFaceM4/idefics2-8b",load_in_4bit=True,quantization_config=bnb_config)
|
| 23 |
|
| 24 |
# if USE_QLORA or USE_LORA:
|
| 25 |
# lora_config = LoraConfig(
|
|
|
|
| 76 |
# submit_btn = gr.Button("Generate")
|
| 77 |
# output = gr.Textbox(label="Model Output")
|
| 78 |
|
| 79 |
+
with gr.Blocks(css="background-color:lightgrey;") as demo:
|
| 80 |
+
gr.Markdown("## IDEFICS2 Demo")
|
| 81 |
with gr.Row():
|
| 82 |
with gr.Column(scale=1):
|
| 83 |
image_input = gr.Image(label="Upload Image", type="pil", tool="editor", height=480, width=640)
|
| 84 |
query_input = gr.Textbox(label="Enter Prompt", placeholder="Type your prompt here...")
|
| 85 |
with gr.Column(scale=1):
|
| 86 |
+
output = gr.Textbox(label="Model Output", interactive=True, placeholder="Output will be displayed here...",lines=12)
|
| 87 |
|
| 88 |
submit_btn = gr.Button("Generate")
|
| 89 |
submit_btn.click(model_inference, inputs=[image_input, query_input], outputs=output)
|