|
|
@@ -34,7 +34,7 @@ class StreamlitOCRValidator:
|
|
|
self.selected_text = None
|
|
|
self.marked_errors = set()
|
|
|
self.file_info = []
|
|
|
- self.selected_file_index = 0
|
|
|
+ self.selected_file_index = -1 # 初始化不指向有效文件index
|
|
|
self.display_options = []
|
|
|
self.file_paths = []
|
|
|
|
|
|
@@ -415,10 +415,17 @@ def main():
|
|
|
st.rerun()
|
|
|
break
|
|
|
|
|
|
- if st.button("🔄 加载文件", type="secondary") and selected_file:
|
|
|
+ if (st.session_state.selected_file_index >= 0
|
|
|
+ and validator.selected_file_index != st.session_state.selected_file_index
|
|
|
+ and selected_file):
|
|
|
+ validator.selected_file_index = st.session_state.selected_file_index
|
|
|
st.session_state.validator.load_ocr_data(selected_file)
|
|
|
- st.success(f"✅ 已加载第{validator.file_info[selected_index]['page']}页")
|
|
|
+ st.success(f"✅ 已加载第{validator.file_info[st.session_state.selected_file_index]['page']}页")
|
|
|
st.rerun()
|
|
|
+ # if st.button("🔄 加载文件", type="secondary") and selected_file:
|
|
|
+ # st.session_state.validator.load_ocr_data(selected_file)
|
|
|
+ # st.success(f"✅ 已加载第{validator.file_info[selected_index]['page']}页")
|
|
|
+ # st.rerun()
|
|
|
else:
|
|
|
st.warning("未找到OCR结果文件")
|
|
|
st.info("请确保output目录下有OCR结果文件")
|
|
|
@@ -431,28 +438,27 @@ def main():
|
|
|
st.session_state.marked_errors = set()
|
|
|
st.rerun()
|
|
|
|
|
|
- # 显示统计信息
|
|
|
- stats = validator.get_statistics()
|
|
|
-
|
|
|
- col1, col2, col3, col4, col5 = st.columns(5) # 增加一列
|
|
|
- with col1:
|
|
|
- st.metric("📊 总文本块", stats['total_texts'])
|
|
|
- with col2:
|
|
|
- st.metric("🔗 可点击文本", stats['clickable_texts'])
|
|
|
- with col3:
|
|
|
- st.metric("❌ 标记错误", stats['marked_errors'])
|
|
|
- with col4:
|
|
|
- st.metric("✅ 准确率", f"{stats['accuracy_rate']:.1f}%")
|
|
|
- with col5:
|
|
|
- # 显示OCR工具信息
|
|
|
+ with st.expander("🔧 OCR工具统计信息", expanded=False):
|
|
|
+ # 显示统计信息
|
|
|
+ stats = validator.get_statistics()
|
|
|
+ col1, col2, col3, col4, col5 = st.columns(5) # 增加一列
|
|
|
+ with col1:
|
|
|
+ st.metric("📊 总文本块", stats['total_texts'])
|
|
|
+ with col2:
|
|
|
+ st.metric("🔗 可点击文本", stats['clickable_texts'])
|
|
|
+ with col3:
|
|
|
+ st.metric("❌ 标记错误", stats['marked_errors'])
|
|
|
+ with col4:
|
|
|
+ st.metric("✅ 准确率", f"{stats['accuracy_rate']:.1f}%")
|
|
|
+ with col5:
|
|
|
+ # 显示OCR工具信息
|
|
|
+ if stats['tool_info']:
|
|
|
+ tool_names = list(stats['tool_info'].keys())
|
|
|
+ main_tool = tool_names[0] if tool_names else "未知"
|
|
|
+ st.metric("🔧 OCR工具", main_tool)
|
|
|
+ # 详细工具信息
|
|
|
if stats['tool_info']:
|
|
|
- tool_names = list(stats['tool_info'].keys())
|
|
|
- main_tool = tool_names[0] if tool_names else "未知"
|
|
|
- st.metric("🔧 OCR工具", main_tool)
|
|
|
-
|
|
|
- # 详细工具信息
|
|
|
- if stats['tool_info']:
|
|
|
- st.expander("🔧 OCR工具详情", expanded=False).write(stats['tool_info'])
|
|
|
+ st.write(stats['tool_info'])
|
|
|
|
|
|
# st.markdown("---")
|
|
|
|