Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ print("Loading PaddleOCR-VL...")
|
|
| 6 |
pipeline = PaddleOCRVL(
|
| 7 |
use_doc_orientation_classify=False,
|
| 8 |
use_doc_unwarping=False,
|
| 9 |
-
use_layout_detection=False,
|
| 10 |
)
|
| 11 |
print("Model loaded!")
|
| 12 |
|
|
@@ -22,14 +22,29 @@ def predict(image):
|
|
| 22 |
|
| 23 |
output = pipeline.predict(temp_path, vl_rec_task="ocr")
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
for res in output:
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
return text_result if text_result else "Нет результата"
|
| 33 |
|
| 34 |
gr.Interface(
|
| 35 |
fn=predict,
|
|
|
|
| 6 |
pipeline = PaddleOCRVL(
|
| 7 |
use_doc_orientation_classify=False,
|
| 8 |
use_doc_unwarping=False,
|
| 9 |
+
use_layout_detection=False,
|
| 10 |
)
|
| 11 |
print("Model loaded!")
|
| 12 |
|
|
|
|
| 22 |
|
| 23 |
output = pipeline.predict(temp_path, vl_rec_task="ocr")
|
| 24 |
|
| 25 |
+
# Отладка - смотрим что вернулось
|
| 26 |
+
for i, res in enumerate(output):
|
| 27 |
+
print(f"\n=== Result {i} ===")
|
| 28 |
+
print(f"Type: {type(res)}")
|
| 29 |
+
print(f"Dir: {[x for x in dir(res) if not x.startswith('_')]}")
|
| 30 |
+
if hasattr(res, '__dict__'):
|
| 31 |
+
print(f"Dict: {res.__dict__.keys()}")
|
| 32 |
+
print(f"Str: {str(res)[:500]}")
|
| 33 |
+
|
| 34 |
+
print(f"\n[{time.strftime('%H:%M:%S')}] Done in {time.time()-t0:.1f}s")
|
| 35 |
+
|
| 36 |
+
# Пробуем разные варианты
|
| 37 |
for res in output:
|
| 38 |
+
# Вариант 1
|
| 39 |
+
if hasattr(res, 'rec_text'):
|
| 40 |
+
return res.rec_text
|
| 41 |
+
# Вариант 2
|
| 42 |
+
if hasattr(res, 'vl_recognition_res'):
|
| 43 |
+
return str(res.vl_recognition_res)
|
| 44 |
+
# Вариант 3 - просто строка
|
| 45 |
+
return str(res)
|
| 46 |
|
| 47 |
+
return "Нет результата"
|
|
|
|
| 48 |
|
| 49 |
gr.Interface(
|
| 50 |
fn=predict,
|