wangleiofficial commited on
Commit
e0285ec
·
verified ·
1 Parent(s): d03f374

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -84,7 +84,7 @@ classifier.eval()
84
  print("✅ Ready.")
85
 
86
  # ==========================
87
- # 3. Panel B: SVG 细胞图 (6类完整显示)
88
  # ==========================
89
  def generate_bacterial_svg(target_class):
90
  target = target_class.lower() if target_class else ""
@@ -104,10 +104,11 @@ def generate_bacterial_svg(target_class):
104
  "bg_text": "#78909C", "bg_line": "#CFD8DC", "bg_dot": "#B0BEC5"
105
  }
106
 
107
- # 结构样式
108
  def style(active, base_fill, base_stroke, w_act="4", w_norm="2"):
109
  if active: return c["hl_fill"], c["hl_stroke"], w_act
110
- return base_fill, base_stroke, width_norm
 
111
 
112
  om_f, om_s, om_w = style(is_peri, c["bg_fill_om"], c["hl_stroke"] if is_om else c["bg_stroke"])
113
  cw_s = c["hl_stroke"] if is_cw else "#B0BEC5"
@@ -206,7 +207,7 @@ def draw_attention_heatmap_strip(weights, sequence):
206
  im = ax.imshow(data, cmap='Reds', aspect='auto', vmin=0, vmax=1)
207
 
208
  # 样式美化
209
- ax.set_title("Sequence Attention Heatmap (High Color = Key Motif)", fontsize=10, fontweight='bold', color='#37474F', pad=10)
210
  ax.set_xlabel("Residue Position", fontsize=9)
211
 
212
  # 隐藏 Y 轴刻度
@@ -332,7 +333,7 @@ with gr.Blocks(theme=theme, css=layout_css, title="LocPred-Prok") as app:
332
  output_label = gr.Label(num_top_classes=NUM_CLASSES, show_label=False)
333
 
334
  with gr.Column(elem_classes="panel-card"):
335
- gr.Markdown("<div class='panel-header'><span class='panel-label'>D</span>Attention Heatmap (Motif Discovery)</div>")
336
  output_plot = gr.Plot(label="Attention", show_label=False)
337
 
338
  submit_btn.click(fn=predict, inputs=sequence_input, outputs=[output_label, output_svg, output_plot])
 
84
  print("✅ Ready.")
85
 
86
  # ==========================
87
+ # 3. Panel B: SVG 细胞图 (修复 NameError)
88
  # ==========================
89
  def generate_bacterial_svg(target_class):
90
  target = target_class.lower() if target_class else ""
 
104
  "bg_text": "#78909C", "bg_line": "#CFD8DC", "bg_dot": "#B0BEC5"
105
  }
106
 
107
+ # 结构样式 (修复了 width_norm 变量名错误)
108
  def style(active, base_fill, base_stroke, w_act="4", w_norm="2"):
109
  if active: return c["hl_fill"], c["hl_stroke"], w_act
110
+ # 修复点:这里原来写成了 width_norm,现已修正为 w_norm
111
+ return base_fill, base_stroke, w_norm
112
 
113
  om_f, om_s, om_w = style(is_peri, c["bg_fill_om"], c["hl_stroke"] if is_om else c["bg_stroke"])
114
  cw_s = c["hl_stroke"] if is_cw else "#B0BEC5"
 
207
  im = ax.imshow(data, cmap='Reds', aspect='auto', vmin=0, vmax=1)
208
 
209
  # 样式美化
210
+ ax.set_title("Sequence Attention Heatmap (High Color = Key Feature)", fontsize=10, fontweight='bold', color='#37474F', pad=10)
211
  ax.set_xlabel("Residue Position", fontsize=9)
212
 
213
  # 隐藏 Y 轴刻度
 
333
  output_label = gr.Label(num_top_classes=NUM_CLASSES, show_label=False)
334
 
335
  with gr.Column(elem_classes="panel-card"):
336
+ gr.Markdown("<div class='panel-header'><span class='panel-label'>D</span>Learned Attention Heatmap</div>")
337
  output_plot = gr.Plot(label="Attention", show_label=False)
338
 
339
  submit_btn.click(fn=predict, inputs=sequence_input, outputs=[output_label, output_svg, output_plot])