gdnjr5233-YOLOer commited on
Commit
2a34866
·
verified ·
1 Parent(s): c554579

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -81,6 +81,10 @@ st.subheader("Upload a Python file with Chinese comments", divider='rainbow')
81
  # 文件上传
82
  uploaded_file = st.file_uploader("Choose .py file", type=['py'], label_visibility='collapsed')
83
 
 
 
 
 
84
  # 初始化模型
85
  if 'models_loaded' not in st.session_state:
86
  with st.spinner('Loading models...'):
@@ -219,8 +223,8 @@ if st.session_state.processed:
219
  avg_ppl = sum(ppl for _, ppl in st.session_state.scores) / len(st.session_state.scores)
220
  st.metric("Average Perplexity", f"{avg_ppl:.4f}", help="Lower is better (Typical range: 1~100+, lower means better translation)")
221
 
222
- # 下载按钮容器(修改点2:独立容器实现居中)
223
- with st.container():
224
  cols = st.columns([1, 2, 1])
225
  with cols[1]:
226
  with tempfile.NamedTemporaryFile(suffix='.py', delete=False) as tmp:
@@ -232,5 +236,5 @@ if st.session_state.processed:
232
  data=f,
233
  file_name=f"translated_{uploaded_file.name}",
234
  mime='text/x-python',
235
- use_container_width=False
236
  )
 
81
  # 文件上传
82
  uploaded_file = st.file_uploader("Choose .py file", type=['py'], label_visibility='collapsed')
83
 
84
+ # 添加开始翻译按钮
85
+ if uploaded_file:
86
+ st.button("开始翻译 / Start Translation", type="primary")
87
+
88
  # 初始化模型
89
  if 'models_loaded' not in st.session_state:
90
  with st.spinner('Loading models...'):
 
223
  avg_ppl = sum(ppl for _, ppl in st.session_state.scores) / len(st.session_state.scores)
224
  st.metric("Average Perplexity", f"{avg_ppl:.4f}", help="Lower is better (Typical range: 1~100+, lower means better translation)")
225
 
226
+ # 下载按钮容器(修改点2:在指标下方居中显示)
227
+ st.markdown("---")
228
  cols = st.columns([1, 2, 1])
229
  with cols[1]:
230
  with tempfile.NamedTemporaryFile(suffix='.py', delete=False) as tmp:
 
236
  data=f,
237
  file_name=f"translated_{uploaded_file.name}",
238
  mime='text/x-python',
239
+ use_container_width=True
240
  )