Vinay15 commited on
Commit
b42b1aa
·
verified ·
1 Parent(s): a8781ff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -1,7 +1,7 @@
1
- import gradio as gr
2
  from transformers import AutoModel, AutoTokenizer
3
  from PIL import Image
4
- import torch
5
 
6
  # Load the OCR model and tokenizer
7
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
@@ -19,14 +19,14 @@ def perform_ocr(image):
19
  result = model.chat(tokenizer, image, ocr_type='ocr')
20
  return result
21
 
22
- # Create the Gradio interface
23
  interface = gr.Interface(
24
  fn=perform_ocr,
25
- inputs=gr.inputs.Image(type="pil"), # Accepts an image input
26
- outputs="text", # Outputs extracted text
27
  title="OCR Web App",
28
  description="Upload an image to extract text using the GOT-OCR2.0 model."
29
  )
30
 
31
  # Launch the app
32
- interface.launch()
 
1
+ import torch
2
  from transformers import AutoModel, AutoTokenizer
3
  from PIL import Image
4
+ import gradio as gr
5
 
6
  # Load the OCR model and tokenizer
7
  tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
 
19
  result = model.chat(tokenizer, image, ocr_type='ocr')
20
  return result
21
 
22
+ # Create the Gradio interface using the new syntax
23
  interface = gr.Interface(
24
  fn=perform_ocr,
25
+ inputs=gr.Image(type="pil"), # Updated to gr.Image
26
+ outputs=gr.Textbox(), # Updated to gr.Textbox
27
  title="OCR Web App",
28
  description="Upload an image to extract text using the GOT-OCR2.0 model."
29
  )
30
 
31
  # Launch the app
32
+ interface.launch(share=True)