sonygod commited on
Commit
62147ba
·
1 Parent(s): 4559f18
Files changed (2) hide show
  1. URL.TXT +4 -0
  2. app.py +27 -20
URL.TXT ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ https://huggingface.co/spaces/sonygod/GOT-OCR
2
+ https://huggingface.co/spaces/Tonic/GOT-OCR
3
+
4
+ https://huggingface.co/spaces/sonygod/OnnxTR-OCR
app.py CHANGED
@@ -12,35 +12,42 @@ def main():
12
 
13
  if st.sidebar.button("分析页面"):
14
  if uploaded_file is None:
15
- st.sidebar.write("请上传一个文档")
16
  return
17
 
18
  if current_page is None:
19
- st.sidebar.write("页面加载失败")
20
  return
21
 
22
  try:
23
- # Process page
24
- start_time = time.time()
25
- model.load_model(**params)
26
- seg_map, out = model.process_page(current_page)
27
-
28
- # Display results
29
- fig, ax = plt.subplots()
30
- ax.imshow(seg_map)
31
- ax.axis("off")
32
- ui.cols[1].pyplot(fig)
33
-
34
- fig = visualize_page(out.pages[0].export(), out.pages[0].page,
35
- interactive=False, add_labels=True)
36
- ui.cols[2].pyplot(fig)
37
-
38
- # Display processing time and results
39
- total_time = time.time() - start_time
40
- st.json({"total_time": total_time, "results": out.pages[0].export()})
 
 
 
 
 
 
41
 
42
  except Exception as e:
43
  st.error(f"处理失败: {str(e)}")
 
44
 
45
  if __name__ == "__main__":
46
  main()
 
12
 
13
  if st.sidebar.button("分析页面"):
14
  if uploaded_file is None:
15
+ st.sidebar.error("请上传一个文档")
16
  return
17
 
18
  if current_page is None:
19
+ st.sidebar.error("页面加载失败")
20
  return
21
 
22
  try:
23
+ with st.spinner('正在处理中...请稍等'):
24
+ st.sidebar.info("开始处理...")
25
+ # Process page
26
+ start_time = time.time()
27
+ st.sidebar.info("加载模型...")
28
+ model.load_model(**params)
29
+ st.sidebar.info("分析页面...")
30
+ seg_map, out = model.process_page(current_page)
31
+
32
+ # Display results
33
+ st.sidebar.info("显示结果...")
34
+ fig, ax = plt.subplots()
35
+ ax.imshow(seg_map)
36
+ ax.axis("off")
37
+ ui.cols[1].pyplot(fig)
38
+
39
+ fig = visualize_page(out.pages[0].export(), out.pages[0].page,
40
+ interactive=False, add_labels=True)
41
+ ui.cols[2].pyplot(fig)
42
+
43
+ # Display processing time and results
44
+ total_time = time.time() - start_time
45
+ st.success(f"处理完成! 用时: {total_time:.2f}秒")
46
+ st.json({"total_time": total_time, "results": out.pages[0].export()})
47
 
48
  except Exception as e:
49
  st.error(f"处理失败: {str(e)}")
50
+ st.sidebar.error("发生错误,请查看详细信息")
51
 
52
  if __name__ == "__main__":
53
  main()