Electro0023 commited on
Commit
abf7c65
·
verified ·
1 Parent(s): 0b154ad

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # This line downloads the model from Hugging Face
5
+ pipe = pipeline("image-text-to-text", model="ibm-granite/granite-docling-258M")
6
+
7
+ def process_image(image):
8
+ # This runs the model on the uploaded image
9
+ result = pipe(image)
10
+ # This returns the text extracted from the document
11
+ return str(result)
12
+
13
+ # This creates the user interface
14
+ demo = gr.Interface(
15
+ fn=process_image,
16
+ inputs=gr.Image(type="pil"),
17
+ outputs="text"
18
+ )
19
+
20
+ # This launches the app
21
+ demo.launch()