Spaces:
Runtime error
Runtime error
File size: 810 Bytes
d8e07ba |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from transformers import Pix2StructProcessor, Pix2StructForConditionalGeneration
import requests
from PIL import Image
import streamlit as st
processor = Pix2StructProcessor.from_pretrained('google/deplot')
model = Pix2StructForConditionalGeneration.from_pretrained('google/deplot')
document = st.file_uploader(label="Upload the document you want to explore",type=["png",'jpg', "jpeg","pdf"])
if document == None:
st.write("Please upload the document in the box above")
else:
image = Image.open(document)
st.image(image,"Document uploaded")
inputs = processor(images=image, text="Generate underlying data table of the figure below:", return_tensors="pt")
predictions = model.generate(**inputs, max_new_tokens=512)
st.write(processor.decode(predictions[0], skip_special_tokens=True)) |