andreamena commited on
Commit
d30b625
·
verified ·
1 Parent(s): bc88720

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -21
app.py CHANGED
@@ -486,31 +486,29 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
486
 
487
  app_mode = gr.Dropdown(
488
  ["Battery Mode", "Biomedical Mode", "Structural Mode"],
489
- value="Battery Mode",
490
  label="Select Optimization Mode"
491
  )
492
- toggle_view = gr.Radio(["Single-objective ranking", "Multi-objective Pareto optimal (Best-in-Class candidates)"], value="Single-objective ranking", label="Selection Strategy")
 
 
 
 
493
 
 
494
  with gr.Row():
 
495
  with gr.Column():
496
  gr.Markdown("""**Application Mapping:**
497
  * **Structural Mode**: Optimized Yield Strength & High Thermal Stability.
498
  * **Battery Mode**: Optimized Glass Transition (Tg) & Conductivity.
499
- * **Biomedical Mode**: Optimized Degradability & Biocompatibility.
500
 
501
- **🧪 Logic Benchmarks:**
502
- * Benchmarks and thresholds adjust automatically based on selected Mode.
503
- * Calculations incorporate Uncertainty (±) for scientific trust.""")
504
- with gr.Column():
505
- gr.Markdown("""**📊 Classification Logic:**
506
- * **✅ Excellent**: Passes **3 or 4** benchmarks simultaneously.
507
- * **⚠️ Review**: Passes exactly **2** benchmarks.
508
- * **❌ Bad**: Passes **0 or 1** benchmark. (Fails 3+ targets)""")
509
-
510
- with gr.Row():
511
- num = gr.Slider(1, 50, 10, step=1, label="Quantity to Generate")
512
- with gr.Accordion("🔒 Constraint-Based Generation (Hard Filters)", open=False):
513
- with gr.Row():
514
  must_have = gr.Dropdown(
515
  [
516
  "Esters (Biodegradable)", "Carbonates (Biodegradable)",
@@ -519,11 +517,27 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
519
  "Urethanes", "Aryl-Monomer", "Aliphatic-Chain"
520
  ],
521
  multiselect=True,
522
- label="Lock Functional Groups & Motifs"
 
523
  )
524
- exclude_aromatic = gr.Checkbox(label="Limit Aromatic Content (<20%)")
525
- max_mol_wt = gr.Slider(100, 1200, 500, label="Specify Max Monomer MW")
526
- run = gr.Button("Run Design Pipeline", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
527
 
528
  pareto_plot = gr.Plot(label="Pareto Frontier")
529
 
@@ -652,7 +666,7 @@ with gr.Blocks(title="PolymerDesignAI") as demo:
652
  smiles = choice.split(" ")[1] if choice and " " in choice else choice
653
  return explain_polymer(smiles, prop)
654
 
655
- run.click(on_gen_complete, [num, app_mode, toggle_view, must_have, exclude_aromatic, max_mol_wt], [results_df, csv_out, pareto_plot, selection_dropdown, full_results_state, explain_img, explain_bar])
656
 
657
  filter_btn_all.click(lambda x: filter_table(x, "All"), full_results_state, results_df)
658
  filter_btn_exc.click(lambda x: filter_table(x, "Excellent"), full_results_state, results_df)
 
486
 
487
  app_mode = gr.Dropdown(
488
  ["Battery Mode", "Biomedical Mode", "Structural Mode"],
489
+ value="Biomedical Mode",
490
  label="Select Optimization Mode"
491
  )
492
+ toggle_view = gr.Radio(
493
+ ["Single-objective ranking", "Multi-objective Pareto optimal (Best-in-Class candidates)"],
494
+ value="Single-objective ranking",
495
+ label="Selection Strategy"
496
+ )
497
 
498
+ # --- MAIN GRID LAYOUT ---
499
  with gr.Row():
500
+ # LEFT COLUMN
501
  with gr.Column():
502
  gr.Markdown("""**Application Mapping:**
503
  * **Structural Mode**: Optimized Yield Strength & High Thermal Stability.
504
  * **Battery Mode**: Optimized Glass Transition (Tg) & Conductivity.
505
+ * **Biomedical Mode**: Optimized Degradability & Biocompatibility.""")
506
 
507
+ num = gr.Slider(1, 50, 10, step=1, label="Quantity to Generate")
508
+
509
+ # Constraint box moved here under Quantity
510
+ with gr.Column(variant="panel"):
511
+ gr.Markdown("🔒 **Constraint-Based Generation (Hard Filters)**")
 
 
 
 
 
 
 
 
512
  must_have = gr.Dropdown(
513
  [
514
  "Esters (Biodegradable)", "Carbonates (Biodegradable)",
 
517
  "Urethanes", "Aryl-Monomer", "Aliphatic-Chain"
518
  ],
519
  multiselect=True,
520
+ label="Lock Functional Groups & Motifs",
521
+ interactive=True # Ensures the dropdown is clickable
522
  )
523
+ with gr.Row():
524
+ exclude_aromatic = gr.Checkbox(label="Limit Aromatic Content (<20%)")
525
+ max_mol_wt = gr.Slider(100, 1200, 500, label="Max Monomer MW")
526
+
527
+ # RIGHT COLUMN
528
+ with gr.Column():
529
+ gr.Markdown("""**📊 Classification Logic:**
530
+ * **✅ Excellent**: Passes **3 or 4** benchmarks simultaneously.
531
+ * **⚠️ Review**: Passes exactly **2** benchmarks.
532
+ * **❌ Bad**: Passes **0 or 1** benchmark. (Fails 3+ targets)""")
533
+
534
+ gr.Markdown("""**🧪 Logic Benchmarks:**
535
+ * Benchmarks and thresholds adjust automatically based on selected Mode.
536
+ * Calculations incorporate Uncertainty (±) for scientific trust.""")
537
+
538
+ # Push button to the bottom of this column
539
+ gr.Markdown("<br><br>")
540
+ run = gr.Button("Run Design Pipeline", variant="primary", size="lg")
541
 
542
  pareto_plot = gr.Plot(label="Pareto Frontier")
543
 
 
666
  smiles = choice.split(" ")[1] if choice and " " in choice else choice
667
  return explain_polymer(smiles, prop)
668
 
669
+ run.click(fn=on_gen_complete, inputs=[num, app_mode, toggle_view, must_have, exclude_aromatic, max_mol_wt], outputs=[results_df, csv_out, pareto_plot, selection_dropdown, full_results_state, explain_img, explain_bar])
670
 
671
  filter_btn_all.click(lambda x: filter_table(x, "All"), full_results_state, results_df)
672
  filter_btn_exc.click(lambda x: filter_table(x, "Excellent"), full_results_state, results_df)