TeddyYao commited on
Commit
0a022f8
·
verified ·
1 Parent(s): 3bf37e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -72,3 +72,18 @@ def main():
72
 
73
  if __name__ == "__main__":
74
  main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  if __name__ == "__main__":
74
  main()
75
+
76
+ if st.button("🧪 运行OCR测试(检查Tesseract是否可用)"):
77
+ try:
78
+ from PIL import ImageDraw
79
+ test_img = Image.new('RGB', (300, 100), color=(255, 255, 255))
80
+ draw = ImageDraw.Draw(test_img)
81
+ draw.text((10, 10), "Hello OCR", fill=(0, 0, 0))
82
+ test_img.save("test_ocr.png")
83
+
84
+ ocr_result = pytesseract.image_to_string(test_img)
85
+ st.success("✅ OCR 正常运行!")
86
+ st.code(ocr_result)
87
+ except Exception as e:
88
+ st.error("❌ OCR 失败,Tesseract 未安装或不可用")
89
+ st.text(str(e))