|
|
@@ -443,7 +443,7 @@ class StreamlitOCRValidator:
|
|
|
}
|
|
|
|
|
|
# 第五步:显示对比结果
|
|
|
- self.display_comparison_results(comparison_result)
|
|
|
+ self.display_comparison_results(comparison_result, detailed=False)
|
|
|
|
|
|
# 第六步:提供文件下载
|
|
|
# self.provide_download_options(pre_validation_dir, vlm_md_path, comparison_result)
|
|
|
@@ -452,7 +452,7 @@ class StreamlitOCRValidator:
|
|
|
st.error(f"❌ VLM预校验失败: {e}")
|
|
|
st.exception(e)
|
|
|
|
|
|
- def display_comparison_results(self, comparison_result: dict):
|
|
|
+ def display_comparison_results(self, comparison_result: dict, detailed: bool = True):
|
|
|
"""显示对比结果摘要 - 使用DataFrame展示"""
|
|
|
|
|
|
st.header("📊 VLM预校验结果")
|
|
|
@@ -567,45 +567,46 @@ class StreamlitOCRValidator:
|
|
|
# 详细差异查看
|
|
|
st.subheader("🔍 详细差异查看")
|
|
|
|
|
|
- # 选择要查看的差异
|
|
|
- selected_diff_index = st.selectbox(
|
|
|
- "选择要查看的差异:",
|
|
|
- options=range(len(comparison_result['differences'])),
|
|
|
- format_func=lambda x: f"差异 {x+1}: {comparison_result['differences'][x]['position']} - {comparison_result['differences'][x]['type']}",
|
|
|
- key="selected_diff"
|
|
|
- )
|
|
|
-
|
|
|
- if selected_diff_index is not None:
|
|
|
- diff = comparison_result['differences'][selected_diff_index]
|
|
|
-
|
|
|
- # 并排显示完整内容
|
|
|
- col1, col2 = st.columns(2)
|
|
|
-
|
|
|
- with col1:
|
|
|
- st.write("**原OCR结果:**")
|
|
|
- st.text_area(
|
|
|
- "原OCR结果详情",
|
|
|
- value=diff['file1_value'],
|
|
|
- height=200,
|
|
|
- key=f"original_{selected_diff_index}",
|
|
|
- label_visibility="collapsed"
|
|
|
- )
|
|
|
-
|
|
|
- with col2:
|
|
|
- st.write("**VLM识别结果:**")
|
|
|
- st.text_area(
|
|
|
- "VLM识别结果详情",
|
|
|
- value=diff['file2_value'],
|
|
|
- height=200,
|
|
|
- key=f"vlm_{selected_diff_index}",
|
|
|
- label_visibility="collapsed"
|
|
|
- )
|
|
|
+ if detailed:
|
|
|
+ # 选择要查看的差异
|
|
|
+ selected_diff_index = st.selectbox(
|
|
|
+ "选择要查看的差异:",
|
|
|
+ options=range(len(comparison_result['differences'])),
|
|
|
+ format_func=lambda x: f"差异 {x+1}: {comparison_result['differences'][x]['position']} - {comparison_result['differences'][x]['type']}",
|
|
|
+ key="selected_diff"
|
|
|
+ )
|
|
|
|
|
|
- # 差异详细信息
|
|
|
- st.info(f"**位置:** {diff['position']}")
|
|
|
- st.info(f"**类型:** {diff['type']}")
|
|
|
- st.info(f"**描述:** {diff['description']}")
|
|
|
- st.info(f"**严重程度:** {self._get_severity_level(diff)}")
|
|
|
+ if selected_diff_index is not None:
|
|
|
+ diff = comparison_result['differences'][selected_diff_index]
|
|
|
+
|
|
|
+ # 并排显示完整内容
|
|
|
+ col1, col2 = st.columns(2)
|
|
|
+
|
|
|
+ with col1:
|
|
|
+ st.write("**原OCR结果:**")
|
|
|
+ st.text_area(
|
|
|
+ "原OCR结果详情",
|
|
|
+ value=diff['file1_value'],
|
|
|
+ height=200,
|
|
|
+ key=f"original_{selected_diff_index}",
|
|
|
+ label_visibility="collapsed"
|
|
|
+ )
|
|
|
+
|
|
|
+ with col2:
|
|
|
+ st.write("**VLM识别结果:**")
|
|
|
+ st.text_area(
|
|
|
+ "VLM识别结果详情",
|
|
|
+ value=diff['file2_value'],
|
|
|
+ height=200,
|
|
|
+ key=f"vlm_{selected_diff_index}",
|
|
|
+ label_visibility="collapsed"
|
|
|
+ )
|
|
|
+
|
|
|
+ # 差异详细信息
|
|
|
+ st.info(f"**位置:** {diff['position']}")
|
|
|
+ st.info(f"**类型:** {diff['type']}")
|
|
|
+ st.info(f"**描述:** {diff['description']}")
|
|
|
+ st.info(f"**严重程度:** {self._get_severity_level(diff)}")
|
|
|
|
|
|
# 差异统计图表
|
|
|
st.subheader("📈 差异类型分布")
|
|
|
@@ -645,7 +646,8 @@ class StreamlitOCRValidator:
|
|
|
st.plotly_chart(fig_severity, use_container_width=True)
|
|
|
|
|
|
# 下载选项
|
|
|
- self._provide_download_options_in_results(comparison_result)
|
|
|
+ if detailed:
|
|
|
+ self._provide_download_options_in_results(comparison_result)
|
|
|
|
|
|
def _get_severity_level(self, diff: dict) -> str:
|
|
|
"""根据差异类型和内容判断严重程度"""
|