cschen commited on
Commit
faa5d8a
Β·
verified Β·
1 Parent(s): fb6848e

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +14 -32
src/app.py CHANGED
@@ -56,37 +56,19 @@ def evaluate_update_dataset():
56
 
57
  for i in range(10):
58
  time.sleep(random.uniform(0.6, 1.2))
59
- t1 = f"""
60
-
61
-
62
- ### πŸ”¨ Iteration **{i+1}**: Cluster and Select Candidates
63
- - The remaining dominated solutions (HEA: R1, AL: R2) are clustered using K-means (K=5), and two candidates per cluster are selected: one closest to the cluster center and one farthest from the non-dominated set (T1, T2).
64
- - **Input**: HEA remaining dominated solutions (R1), AL remaining dominated solutions (R2), Number of clusters (K=5)
65
- - **Output**: Candidate solutions (C1 for HEA, C2 for AL)
66
- """
67
- t2 = f"""
68
-
69
-
70
- ### πŸ”¨ Iteration **{i+1}**: Evaluate and Update Non-Dominated Sets
71
- - The LLM evaluates candidates (C1, C2) based on prediction error, selecting those with the highest error for inclusion in the non-dominated sets (T1, T2), and removing them from the remaining solutions (R1, R2).
72
- - **Input**: Candidate solutions (C1, C2), Non-dominated solution sets (T1, T2), Knowledge Books (K1_{i}, K2_{i})
73
- - **Output**: Updated non-dominated solution sets (T1, T2), Updated remaining solutions (R1, R2)
74
- """
75
- t3 = f"""
76
-
77
-
78
- ### πŸ”¨ Iteration **{i+1}**: Update Knowledge Books
79
- - The LLM updates the Knowledge Books (K1_{i}, K2_{i}) by incorporating newly added solutions (T1, T2), adjusting based on prediction errors on test data, and refining knowledge from the previous iteration of Knowledge Books.
80
- - **Input**: Updated non-dominated solution sets (T1, T2), Candidate solutions (C1, C2), Previous Knowledge Books (K1_{i}, K2_{i})
81
- - **Output**: Updated Knowledge Books (K1_{i+1}, K2_{i+1})
82
- """
83
- yield t1, *updated_hea_buttons, *updated_al_buttons
84
  time.sleep(random.uniform(1, 1.8))
85
- yield t2, *updated_hea_buttons, *updated_al_buttons
 
 
86
  time.sleep(random.uniform(1, 1.8))
87
  updated_hea_buttons = [gr.update(visible=True) if j == i else gr.update() for j in range(10)]
88
  updated_al_buttons = [gr.update(visible=True) if j == i else gr.update() for j in range(10)]
89
- yield t3, *updated_hea_buttons, *updated_al_buttons # Unpacking buttons properly
 
 
90
 
91
  yield "πŸŽ‰ All Knowledge books updated!", *[gr.update() for _ in range(10)], *[gr.update() for _ in range(10)]
92
 
@@ -121,7 +103,7 @@ with gr.Blocks(title="AISG - MCMOOHD") as demo:
121
 
122
  hea_file.change(load_dataset, inputs=[hea_file], outputs=[hea_data, hea_button])
123
  step1_next_button = gr.Button("Next step", interactive=False)
124
- step1_next_button.click(lambda: change_tab(1), inputs=[], outputs=[tabs])
125
 
126
 
127
  with gr.Tab("Step 2: Optimization on AL alloy data", id=1, interactive=False) as step2:
@@ -138,7 +120,7 @@ with gr.Blocks(title="AISG - MCMOOHD") as demo:
138
 
139
  al_file.change(load_dataset, inputs=[al_file], outputs=[al_data, al_button])
140
  step2_next_button = gr.Button("Next step", interactive=False)
141
- step2_next_button.click(lambda: change_tab(2), inputs=[], outputs=[tabs])
142
 
143
 
144
  with gr.Tab("Step 3: Composite Solutions", id=2, interactive=False) as step3:
@@ -151,7 +133,7 @@ with gr.Blocks(title="AISG - MCMOOHD") as demo:
151
  merge_label = gr.Label("Composite data", visible=True)
152
  merged_data = gr.Dataframe(label="Composited data", visible=False, show_fullscreen_button=True, show_copy_button=True, show_search=True)
153
  step3_next_button = gr.Button("Next step", interactive=False)
154
- step3_next_button.click(lambda: change_tab(3), inputs=[], outputs=[tabs])
155
 
156
 
157
  with gr.Tab("Step 4: Generate Knowledge Books (LLM)", id=3, interactive=False) as step4:
@@ -179,7 +161,7 @@ with gr.Blocks(title="AISG - MCMOOHD") as demo:
179
  heak_button.click(lambda: show_knowledge("HEA_knowledge2_0.txt"), inputs=None, outputs=[modal, modal_content])
180
  alk_button.click(lambda: show_knowledge("AL_knowledge2_0.txt"), inputs=None, outputs=[modal, modal_content])
181
  step4_next_button = gr.Button("Next step", interactive=False)
182
- step4_next_button.click(lambda: change_tab(4), inputs=[], outputs=[tabs])
183
 
184
 
185
  with gr.Tab("Step 5. Update Knowledge Books (LLM)", id=4, interactive=False) as step5:
@@ -231,7 +213,7 @@ with gr.Blocks(title="AISG - MCMOOHD") as demo:
231
  ual_buttons.append(gr.Button(f"AL alloy Knowledge Book {i+1}", visible=False))
232
  ual_buttons[i].click(lambda: show_knowledge(f"AL_knowledge2_{i+1}.txt"), inputs=None, outputs=[modal, modal_content])
233
  step5_next_button = gr.Button("Next step", interactive=False)
234
- step5_next_button.click(lambda: change_tab(5), inputs=[], outputs=[tabs])
235
 
236
 
237
  with gr.Tab("Step 6: Suggested New HEA (LLM)", id=5, interactive=False) as step6:
 
56
 
57
  for i in range(10):
58
  time.sleep(random.uniform(0.6, 1.2))
59
+ t = PROCESSING_TEXT.format(prev_index=i, index=i+1, color1=ACTIVE_FRAME_COLOR, text_color1=ACTIVE_TEXT_COLOR, color2=DEFAULT_FRAME_COLOR, text_color2=DEFAULT_TEXT_COLOR,
60
+ color3=DEFAULT_FRAME_COLOR, text_color3=DEFAULT_TEXT_COLOR, icon1="πŸš€", icon2="", icon3="")
61
+ yield t, *updated_hea_buttons, *updated_al_buttons
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  time.sleep(random.uniform(1, 1.8))
63
+ t = PROCESSING_TEXT.format(prev_index=i, index=i+1, color1=DEFAULT_FRAME_COLOR, text_color1=DEFAULT_TEXT_COLOR, color2=ACTIVE_FRAME_COLOR, text_color2=ACTIVE_TEXT_COLOR,
64
+ color3=DEFAULT_FRAME_COLOR, text_color3=DEFAULT_TEXT_COLOR, icon1="", icon2="πŸš€", icon3="")
65
+ yield t, *updated_hea_buttons, *updated_al_buttons
66
  time.sleep(random.uniform(1, 1.8))
67
  updated_hea_buttons = [gr.update(visible=True) if j == i else gr.update() for j in range(10)]
68
  updated_al_buttons = [gr.update(visible=True) if j == i else gr.update() for j in range(10)]
69
+ t = PROCESSING_TEXT.format(prev_index=i, index=i+1, color1=DEFAULT_FRAME_COLOR, text_color1=DEFAULT_TEXT_COLOR, color2=DEFAULT_FRAME_COLOR, text_color2=DEFAULT_TEXT_COLOR,
70
+ color3=ACTIVE_FRAME_COLOR, text_color3=ACTIVE_TEXT_COLOR, icon1="", icon2="", icon3="πŸš€")
71
+ yield t, *updated_hea_buttons, *updated_al_buttons # Unpacking buttons properly
72
 
73
  yield "πŸŽ‰ All Knowledge books updated!", *[gr.update() for _ in range(10)], *[gr.update() for _ in range(10)]
74
 
 
103
 
104
  hea_file.change(load_dataset, inputs=[hea_file], outputs=[hea_data, hea_button])
105
  step1_next_button = gr.Button("Next step", interactive=False)
106
+ step1_next_button.click(lambda: change_tab(1), inputs=[], outputs=[tabs], js="()=>window.scrollTo({ top: 0, behavior: 'smooth' })")
107
 
108
 
109
  with gr.Tab("Step 2: Optimization on AL alloy data", id=1, interactive=False) as step2:
 
120
 
121
  al_file.change(load_dataset, inputs=[al_file], outputs=[al_data, al_button])
122
  step2_next_button = gr.Button("Next step", interactive=False)
123
+ step2_next_button.click(lambda: change_tab(2), inputs=[], outputs=[tabs], js="()=>window.scrollTo({ top: 0, behavior: 'smooth' })")
124
 
125
 
126
  with gr.Tab("Step 3: Composite Solutions", id=2, interactive=False) as step3:
 
133
  merge_label = gr.Label("Composite data", visible=True)
134
  merged_data = gr.Dataframe(label="Composited data", visible=False, show_fullscreen_button=True, show_copy_button=True, show_search=True)
135
  step3_next_button = gr.Button("Next step", interactive=False)
136
+ step3_next_button.click(lambda: change_tab(3), inputs=[], outputs=[tabs], js="()=>window.scrollTo({ top: 0, behavior: 'smooth' })")
137
 
138
 
139
  with gr.Tab("Step 4: Generate Knowledge Books (LLM)", id=3, interactive=False) as step4:
 
161
  heak_button.click(lambda: show_knowledge("HEA_knowledge2_0.txt"), inputs=None, outputs=[modal, modal_content])
162
  alk_button.click(lambda: show_knowledge("AL_knowledge2_0.txt"), inputs=None, outputs=[modal, modal_content])
163
  step4_next_button = gr.Button("Next step", interactive=False)
164
+ step4_next_button.click(lambda: change_tab(4), inputs=[], outputs=[tabs], js="()=>window.scrollTo({ top: 0, behavior: 'smooth' })")
165
 
166
 
167
  with gr.Tab("Step 5. Update Knowledge Books (LLM)", id=4, interactive=False) as step5:
 
213
  ual_buttons.append(gr.Button(f"AL alloy Knowledge Book {i+1}", visible=False))
214
  ual_buttons[i].click(lambda: show_knowledge(f"AL_knowledge2_{i+1}.txt"), inputs=None, outputs=[modal, modal_content])
215
  step5_next_button = gr.Button("Next step", interactive=False)
216
+ step5_next_button.click(lambda: change_tab(5), inputs=[], outputs=[tabs], js="()=>window.scrollTo({ top: 0, behavior: 'smooth' })")
217
 
218
 
219
  with gr.Tab("Step 6: Suggested New HEA (LLM)", id=5, interactive=False) as step6: