Update app.py
Browse files
app.py
CHANGED
|
@@ -17,9 +17,9 @@ model.to(device)
|
|
| 17 |
# result = processor.decode(outputs[0], skip_special_tokens=True)
|
| 18 |
# return result
|
| 19 |
|
| 20 |
-
def extract_chart_data(img: Image.Image):
|
| 21 |
# Provide a header prompt for VQA
|
| 22 |
-
header_text = "Convert this bar chart into a table of quarter and cost values"
|
| 23 |
|
| 24 |
inputs = processor(images=img, text=header_text, return_tensors="pt").to(device)
|
| 25 |
outputs = model.generate(**inputs)
|
|
@@ -30,9 +30,16 @@ def extract_chart_data(img: Image.Image):
|
|
| 30 |
# Gradio interface
|
| 31 |
iface = gr.Interface(
|
| 32 |
fn=extract_chart_data,
|
| 33 |
-
inputs=gr.Image(type="pil"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
outputs="text",
|
| 35 |
-
title="DePlot Chart Data Extractor
|
| 36 |
description="Upload a chart image and get its extracted data/description."
|
| 37 |
)
|
| 38 |
|
|
|
|
| 17 |
# result = processor.decode(outputs[0], skip_special_tokens=True)
|
| 18 |
# return result
|
| 19 |
|
| 20 |
+
def extract_chart_data(img: Image.Image, header_text:str):
|
| 21 |
# Provide a header prompt for VQA
|
| 22 |
+
# header_text = "Convert this bar chart into a table of quarter and cost values"
|
| 23 |
|
| 24 |
inputs = processor(images=img, text=header_text, return_tensors="pt").to(device)
|
| 25 |
outputs = model.generate(**inputs)
|
|
|
|
| 30 |
# Gradio interface
|
| 31 |
iface = gr.Interface(
|
| 32 |
fn=extract_chart_data,
|
| 33 |
+
# inputs=gr.Image(type="pil"),
|
| 34 |
+
inputs=[
|
| 35 |
+
gr.Image(type="pil", label="Upload Chart Image"), # Image input
|
| 36 |
+
gr.Textbox(
|
| 37 |
+
label="Instruction / Header Text",
|
| 38 |
+
placeholder="Enter instructions like 'Convert this bar chart into a table of quarter and cost values'"
|
| 39 |
+
) # Text input
|
| 40 |
+
],
|
| 41 |
outputs="text",
|
| 42 |
+
title="DePlot Chart Data Extractor 2",
|
| 43 |
description="Upload a chart image and get its extracted data/description."
|
| 44 |
)
|
| 45 |
|