Maskedxx commited on
Commit
d37d4c9
·
verified ·
1 Parent(s): 0d7536c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -7
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, # Отключаем layout!
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
- text_result = ""
 
 
 
 
 
 
 
 
 
 
27
  for res in output:
28
- if hasattr(res, 'vl_recognition_res') and res.vl_recognition_res:
29
- text_result = res.vl_recognition_res.get('rec_text', '')
 
 
 
 
 
 
30
 
31
- print(f"[{time.strftime('%H:%M:%S')}] Done in {time.time()-t0:.1f}s")
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,