Spaces:
Running
on
Zero
Running
on
Zero
fix: got_ocr
Browse files- app.py +1 -1
- got_ocr.py +2 -2
app.py
CHANGED
@@ -74,7 +74,7 @@ def perform_ocr(selected_index, image_paths):
|
|
74 |
if selected_index is not None and image_paths and 0 <= selected_index < len(image_paths):
|
75 |
selected_image = image_paths[selected_index][0]
|
76 |
# 这里添加OCR处理逻辑
|
77 |
-
return got_ocr(model, selected_image)
|
78 |
return "请先选择一个图片"
|
79 |
|
80 |
|
|
|
74 |
if selected_index is not None and image_paths and 0 <= selected_index < len(image_paths):
|
75 |
selected_image = image_paths[selected_index][0]
|
76 |
# 这里添加OCR处理逻辑
|
77 |
+
return got_ocr(model, tokenizer, selected_image)
|
78 |
return "请先选择一个图片"
|
79 |
|
80 |
|
got_ocr.py
CHANGED
@@ -2,7 +2,7 @@ import base64
|
|
2 |
import os
|
3 |
|
4 |
|
5 |
-
def got_ocr(model, image_path, got_mode="plain texts OCR", fine_grained_mode="", ocr_color="", ocr_box=""):
|
6 |
# 执行OCR
|
7 |
try:
|
8 |
if got_mode == "plain texts OCR":
|
@@ -47,7 +47,7 @@ if __name__ == "__main__":
|
|
47 |
model = model.eval().cuda()
|
48 |
|
49 |
image_path = "path/to/your/image.png"
|
50 |
-
result, html = got_ocr(model, image_path, got_mode="format texts OCR")
|
51 |
print("OCR结果:", result)
|
52 |
if html:
|
53 |
print("HTML结果可用")
|
|
|
2 |
import os
|
3 |
|
4 |
|
5 |
+
def got_ocr(model, tokenizer, image_path, got_mode="plain texts OCR", fine_grained_mode="", ocr_color="", ocr_box=""):
|
6 |
# 执行OCR
|
7 |
try:
|
8 |
if got_mode == "plain texts OCR":
|
|
|
47 |
model = model.eval().cuda()
|
48 |
|
49 |
image_path = "path/to/your/image.png"
|
50 |
+
result, html = got_ocr(model, tokenizer, image_path, got_mode="format texts OCR")
|
51 |
print("OCR结果:", result)
|
52 |
if html:
|
53 |
print("HTML结果可用")
|