TeddyYao commited on
Commit
6b904b1
·
verified ·
1 Parent(s): 75be304

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -63,18 +63,17 @@ def main():
63
  else:
64
  st.warning("请上传双方截图")
65
 
66
- if st.button("🧪 OCR 测试"):
67
- try:
68
- from PIL import ImageDraw
69
- test_img = Image.new('RGB', (300, 100), color=(255, 255, 255))
70
- draw = ImageDraw.Draw(test_img)
71
- draw.text((10, 10), "Hello OCR", fill=(0, 0, 0))
72
- ocr_text = pytesseract.image_to_string(test_img)
73
- st.success("OCR 正常运行!")
74
- st.code(ocr_text)
75
- except Exception as e:
76
- st.error("❌ OCR 错误,Tesseract 没有正确安装")
77
- st.text(str(e))
78
 
79
  if __name__ == "__main__":
80
  main()
 
63
  else:
64
  st.warning("请上传双方截图")
65
 
66
+ import subprocess
67
+
68
+ with st.expander("🛠️ 查看 Tesseract 安装状态(调试用)"):
69
+ try:
70
+ version = subprocess.check_output(["tesseract", "--version"])
71
+ st.success("✅ Tesseract 已安装")
72
+ st.code(version.decode(), language="bash")
73
+ except Exception as e:
74
+ st.error("❌ Tesseract 未安装")
75
+ st.text(str(e))
76
+
 
77
 
78
  if __name__ == "__main__":
79
  main()