Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
import
|
2 |
from transformers import AutoModel, AutoTokenizer
|
3 |
from PIL import Image
|
4 |
-
import
|
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.
|
26 |
-
outputs=
|
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)
|