OmidSakaki commited on
Commit
28a9f71
·
verified ·
1 Parent(s): 54a29b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -10
app.py CHANGED
@@ -34,7 +34,6 @@ def full_processing(image: np.ndarray) -> Tuple[str, str]:
34
  ocr_text = OCRProcessor().extract_text(image)
35
  post_processor = TextPostProcessor()
36
  cleaned_text = post_processor.preprocess(ocr_text)
37
- # بازنویسی واقعی انجام نمی‌شود، فقط متن تمیز می‌شود
38
  return cleaned_text, cleaned_text
39
  except Exception as e:
40
  return f"خطا: {str(e)}", ""
@@ -42,21 +41,16 @@ def full_processing(image: np.ndarray) -> Tuple[str, str]:
42
  with gr.Blocks(title="پایپلاین OCR و تصحیح متن فارسی") as app:
43
  gr.Markdown("""
44
  # استخراج و تصحیح متن فارسی از تصویر
45
- فقط متن را تصحیح (نرمال‌سازی) می‌کند و بازنویسی واقعی انجام نمی‌دهد.
46
  """)
 
47
  with gr.Row():
48
  with gr.Column():
49
  img_input = gr.Image(label="تصویر ورودی", type="numpy")
50
  process_btn = gr.Button("پردازش تصویر", variant="primary")
51
  with gr.Column():
52
- with gr.Tab("متن استخراج شده"):
53
- raw_output = gr.Textbox(label="متن استخراج شده")
54
- with gr.Tab("متن نهایی (تصحیح شده)"):
55
- enhanced_output = gr.Textbox(label="متن نهایی")
56
- with gr.Tab("پیش‌نمایش تصویر"):
57
- img_preview = gr.Image(label="", interactive=False)
58
-
59
- img_input.change(fn=lambda x: x, inputs=img_input, outputs=img_preview)
60
  process_btn.click(fn=full_processing, inputs=img_input, outputs=[raw_output, enhanced_output])
61
 
62
  if __name__ == "__main__":
 
34
  ocr_text = OCRProcessor().extract_text(image)
35
  post_processor = TextPostProcessor()
36
  cleaned_text = post_processor.preprocess(ocr_text)
 
37
  return cleaned_text, cleaned_text
38
  except Exception as e:
39
  return f"خطا: {str(e)}", ""
 
41
  with gr.Blocks(title="پایپلاین OCR و تصحیح متن فارسی") as app:
42
  gr.Markdown("""
43
  # استخراج و تصحیح متن فارسی از تصویر
 
44
  """)
45
+
46
  with gr.Row():
47
  with gr.Column():
48
  img_input = gr.Image(label="تصویر ورودی", type="numpy")
49
  process_btn = gr.Button("پردازش تصویر", variant="primary")
50
  with gr.Column():
51
+ raw_output = gr.Textbox(label="متن استخراج شده", lines=8, max_lines=None)
52
+ enhanced_output = gr.Textbox(label="متن نهایی", lines=10, max_lines=None)
53
+
 
 
 
 
 
54
  process_btn.click(fn=full_processing, inputs=img_input, outputs=[raw_output, enhanced_output])
55
 
56
  if __name__ == "__main__":