ankush-003 commited on
Commit
402f471
·
1 Parent(s): 3eaa6dc

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +7 -3
  2. requirements.txt +0 -0
app.py CHANGED
@@ -2,9 +2,11 @@ from doctr.io import DocumentFile
2
  from doctr.models import ocr_predictor
3
  from PIL import Image
4
  import gradio as gr
 
5
 
6
  # Load the model
7
  predictor = ocr_predictor(pretrained=True)
 
8
 
9
  def read_img(image):
10
  # save image
@@ -15,13 +17,15 @@ def read_img(image):
15
  # Run the model
16
  result = predictor(doc)
17
  # Return the result
18
- return result.render(), result.show(doc)
 
 
19
 
20
  app = gr.Interface(
21
  title="Image OCR",
22
  description="Extract text from images",
23
- inputs=gr.Image(type="pil"),
24
- outputs=[gr.Textbox(), gr.Image()],
25
  fn=read_img
26
  )
27
 
 
2
  from doctr.models import ocr_predictor
3
  from PIL import Image
4
  import gradio as gr
5
+ from transformers import pipeline
6
 
7
  # Load the model
8
  predictor = ocr_predictor(pretrained=True)
9
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
10
 
11
  def read_img(image):
12
  # save image
 
17
  # Run the model
18
  result = predictor(doc)
19
  # Return the result
20
+ image_text = result.render()
21
+ summary_text = summarizer(image_text, max_length=150, min_length=50, do_sample=False)
22
+ return image_text, summary_text, result.show(doc)
23
 
24
  app = gr.Interface(
25
  title="Image OCR",
26
  description="Extract text from images",
27
+ inputs=gr.Image(type="pil", label="Input image"),
28
+ outputs=[gr.Textbox(label="Image Text"), gr.Textbox(label="Summary"), gr.Image(label="Image")],
29
  fn=read_img
30
  )
31
 
requirements.txt CHANGED
Binary files a/requirements.txt and b/requirements.txt differ