namelessai commited on
Commit
695027d
·
verified ·
1 Parent(s): 9f7d3ee

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
+ # Initialize the image-to-text pipeline
5
+ extractor = pipeline("image-to-text", model="microsoft/git-base-textcaps")
6
+
7
+ def extract_text(image):
8
+ result = extractor(image)
9
+ return result[0]['generated_text']
10
+
11
+ # Create the Gradio interface
12
+ iface = gr.Interface(
13
+ fn=extract_text,
14
+ inputs=gr.Image(type="pil"),
15
+ outputs="text",
16
+ title="Image Text Extractor",
17
+ description="Upload an image to extract text using Hugging Face's image-to-text model."
18
+ )
19
+
20
+ # Launch the app
21
+ iface.launch()