Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModel, AutoTokenizer
|
3 |
from PIL import Image
|
|
|
4 |
|
5 |
# Load the tokenizer and model
|
6 |
tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
|
@@ -14,8 +15,11 @@ def perform_ocr(image):
|
|
14 |
if image.mode != "RGB":
|
15 |
image = image.convert("RGB")
|
16 |
|
|
|
|
|
|
|
17 |
# Perform OCR using the model
|
18 |
-
res = model.chat(tokenizer,
|
19 |
|
20 |
return res
|
21 |
except Exception as e:
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModel, AutoTokenizer
|
3 |
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
|
6 |
# Load the tokenizer and model
|
7 |
tokenizer = AutoTokenizer.from_pretrained('ucaslcl/GOT-OCR2_0', trust_remote_code=True)
|
|
|
15 |
if image.mode != "RGB":
|
16 |
image = image.convert("RGB")
|
17 |
|
18 |
+
# Convert the image to a format suitable for the model (if needed)
|
19 |
+
image_array = np.array(image)
|
20 |
+
|
21 |
# Perform OCR using the model
|
22 |
+
res = model.chat(tokenizer, image_array, ocr_type='ocr') # Adjusted to pass the image array
|
23 |
|
24 |
return res
|
25 |
except Exception as e:
|