Spaces:
Build error
Build error
Update app.py
Browse files2 unmodified lines345678678910112 unmodified lines14151617171819201 unmodified line222324252526272 unmodified linesfrom PIL import Imageimport torch
# Load Donut model and processormodel = VisionEncoderDecoderModel.from_pretrained("naver-clova-ix/donut-base")processor = DonutProcessor.from_pretrained("naver-clova-ix/donut-base")# Load a smaller model for testing (adjust to a smaller one)model = VisionEncoderDecoderModel.from_pretrained("nlpconnect/vit-gpt2-image-captioning")processor = DonutProcessor.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
# Define function to convert image to textdef image_to_text(image):2 unmodified lines text = processor.batch_decode(output_ids, skip_special_tokens=True)[0] return text.strip()
# Define the Gradio Blocks interface for image input and text output# Gradio interface setupwith gr.Blocks() as demo: with gr.Row(): img_input = gr.Image(type="pil", label="Upload Image")1 unmodified line
img_input.change(image_to_text, inputs=img_input, outputs=text_output)
# Run the interface# Start the Gradio interfaceif __name__ == "__main__": demo.launch()app.py+5-5