alan918727 commited on
Commit
603cd4e
·
verified ·
1 Parent(s): 15fdf16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -54,10 +54,10 @@ def get_features_single(formula):
54
 
55
  def predict_features(formula):
56
  try:
57
- # 验证化学式的有效性
58
  try:
59
- comp = Composition(formula) # 如果无效会抛出异常
60
- _ = comp.get_reduced_formula_and_factor() # 进一步验证
61
  except Exception:
62
  return {"Error": "Invalid chemical formula. Please check your input and try again."}
63
 
@@ -135,7 +135,6 @@ def gradio_ui():
135
  def update_output(formula):
136
  result = predict_features(formula)
137
  if "Error" in result:
138
- # 返回错误消息到 Gradio 界面
139
  return f"Error: {result['Error']}", []
140
  return result.get("Predicted Layer Group Name", "Unknown"), result.get("Top 5 Predictions", [])
141
 
 
54
 
55
  def predict_features(formula):
56
  try:
57
+
58
  try:
59
+ comp = Composition(formula)
60
+ _ = comp.get_reduced_formula_and_factor()
61
  except Exception:
62
  return {"Error": "Invalid chemical formula. Please check your input and try again."}
63
 
 
135
  def update_output(formula):
136
  result = predict_features(formula)
137
  if "Error" in result:
 
138
  return f"Error: {result['Error']}", []
139
  return result.get("Predicted Layer Group Name", "Unknown"), result.get("Top 5 Predictions", [])
140