Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files- src/app.py +13 -13
src/app.py
CHANGED
|
@@ -73,13 +73,13 @@ def evaluate_merged_data():
|
|
| 73 |
df = pd.read_csv("./data/Final_output.csv")
|
| 74 |
return df, gr.update(visible=True), gr.update(visible=False)
|
| 75 |
|
| 76 |
-
with gr.Blocks() as demo:
|
| 77 |
gr.Markdown("# 🚀 Materail AI - HEA & AL")
|
| 78 |
|
| 79 |
with Modal(visible=False) as modal:
|
| 80 |
modal_content = gr.Markdown("Hello world!")
|
| 81 |
|
| 82 |
-
with gr.
|
| 83 |
gr.Markdown("**Inputs**: HEA dataset. **Outputs**: Optimized HEA Dataset.")
|
| 84 |
with gr.Row():
|
| 85 |
hea_file = gr.File(label="Upload HEA Dataset (CSV)")
|
|
@@ -91,7 +91,7 @@ with gr.Blocks() as demo:
|
|
| 91 |
hea_file.change(load_dataset, inputs=[hea_file], outputs=[hea_data, hea_button])
|
| 92 |
|
| 93 |
|
| 94 |
-
with gr.
|
| 95 |
gr.Markdown("**Inputs**: AL dataset. **Outputs**: Optimized AL dataset.")
|
| 96 |
with gr.Row():
|
| 97 |
al_file = gr.File(label="Upload AL Dataset (CSV)")
|
|
@@ -103,14 +103,14 @@ with gr.Blocks() as demo:
|
|
| 103 |
al_file.change(load_dataset, inputs=[al_file], outputs=[al_data, al_button])
|
| 104 |
|
| 105 |
|
| 106 |
-
with gr.
|
| 107 |
gr.Markdown("**Inputs**: Optimized HEA and AL datasets. **Outputs**: Composited dataset.")
|
| 108 |
merge_button = gr.Button("Composite Data", interactive=False)
|
| 109 |
merge_label = gr.Label("Composite Data", visible=True)
|
| 110 |
merged_data = gr.Dataframe(label="Composited Dataset", visible=False, show_fullscreen_button=True, show_copy_button=True, show_search=True)
|
| 111 |
|
| 112 |
|
| 113 |
-
with gr.
|
| 114 |
gr.Markdown("**Inputs**: HEA and AL dataset. **Outputs**: HEA Knowledge Book and AL Knowledge Book.")
|
| 115 |
with gr.Row():
|
| 116 |
with gr.Column():
|
|
@@ -132,7 +132,7 @@ with gr.Blocks() as demo:
|
|
| 132 |
alk_button.click(lambda: show_knowledge("AL_knowledge2_0.txt"), inputs=None, outputs=[modal, modal_content])
|
| 133 |
|
| 134 |
|
| 135 |
-
with gr.
|
| 136 |
gr.Markdown("**Inputs**: HEA and AL dataset and Knowledge Books. **Outputs**: Updated HEA and AL Knowledge Books.")
|
| 137 |
gr.Markdown("**Evaluate Candidates**")
|
| 138 |
with gr.Row():
|
|
@@ -178,7 +178,7 @@ with gr.Blocks() as demo:
|
|
| 178 |
ual_buttons[i].click(lambda: show_knowledge(f"AL_knowledge2_{i+1}.txt"), inputs=None, outputs=[modal, modal_content])
|
| 179 |
|
| 180 |
|
| 181 |
-
with gr.
|
| 182 |
gr.Markdown("**Inputs**: Composited Dataset and Knowledge Books. **Outputs**: Predicted YS UTS Elongation values.")
|
| 183 |
predict_prompt = gr.Textbox(label="LLM Prompt Template to Update HEA Knowledge Book", value=PREDICT_PROMPT, lines = 6,
|
| 184 |
interactive=False, autoscroll=True)
|
|
@@ -189,16 +189,16 @@ with gr.Blocks() as demo:
|
|
| 189 |
|
| 190 |
optimized_data = gr.State(0)
|
| 191 |
|
| 192 |
-
hea_button.click(optimize_HEA_dataset, inputs=[optimized_data], outputs=[hea_optimized, optimized_data, merge_button], show_progress=True).then(lambda: gr.update(
|
| 193 |
-
al_button.click(optimize_AL_dataset, inputs=[optimized_data], outputs=[al_optimized, optimized_data, merge_button]).then(lambda: gr.update(
|
| 194 |
-
merge_button.click(merge_datasets, inputs=[hea_optimized, al_optimized], outputs=[merged_data, merged_data, merge_label]).then(lambda: tuple([gr.update(
|
| 195 |
gen_kbook_button.click(
|
| 196 |
generate_knowledge_book,
|
| 197 |
inputs=None,
|
| 198 |
outputs=[heak_button, alk_button, gen_kbook_label, gen_kbook],
|
| 199 |
-
).then(lambda: tuple([gr.update(
|
| 200 |
-
update_kbook_button.click(evaluate_update_dataset, inputs=None, outputs=[output_text, *uhea_buttons, *ual_buttons]).then(lambda: tuple([gr.update(
|
| 201 |
predict_button.click(evaluate_merged_data, inputs=None, outputs=[predict_data, predict_data, predict_label])
|
| 202 |
|
| 203 |
if __name__ == "__main__":
|
| 204 |
-
demo.launch(
|
|
|
|
| 73 |
df = pd.read_csv("./data/Final_output.csv")
|
| 74 |
return df, gr.update(visible=True), gr.update(visible=False)
|
| 75 |
|
| 76 |
+
with gr.Blocks(title="Material AI") as demo:
|
| 77 |
gr.Markdown("# 🚀 Materail AI - HEA & AL")
|
| 78 |
|
| 79 |
with Modal(visible=False) as modal:
|
| 80 |
modal_content = gr.Markdown("Hello world!")
|
| 81 |
|
| 82 |
+
with gr.Tab("Step 1: Optimize HEA Dataset", interactive=True) as step1:
|
| 83 |
gr.Markdown("**Inputs**: HEA dataset. **Outputs**: Optimized HEA Dataset.")
|
| 84 |
with gr.Row():
|
| 85 |
hea_file = gr.File(label="Upload HEA Dataset (CSV)")
|
|
|
|
| 91 |
hea_file.change(load_dataset, inputs=[hea_file], outputs=[hea_data, hea_button])
|
| 92 |
|
| 93 |
|
| 94 |
+
with gr.Tab("Step 2: Optimize AL Dataset", interactive=False) as step2:
|
| 95 |
gr.Markdown("**Inputs**: AL dataset. **Outputs**: Optimized AL dataset.")
|
| 96 |
with gr.Row():
|
| 97 |
al_file = gr.File(label="Upload AL Dataset (CSV)")
|
|
|
|
| 103 |
al_file.change(load_dataset, inputs=[al_file], outputs=[al_data, al_button])
|
| 104 |
|
| 105 |
|
| 106 |
+
with gr.Tab("Step 3: Composite Data", interactive=False) as step3:
|
| 107 |
gr.Markdown("**Inputs**: Optimized HEA and AL datasets. **Outputs**: Composited dataset.")
|
| 108 |
merge_button = gr.Button("Composite Data", interactive=False)
|
| 109 |
merge_label = gr.Label("Composite Data", visible=True)
|
| 110 |
merged_data = gr.Dataframe(label="Composited Dataset", visible=False, show_fullscreen_button=True, show_copy_button=True, show_search=True)
|
| 111 |
|
| 112 |
|
| 113 |
+
with gr.Tab("Step 4: Generate Knowledge Books (LLM)", interactive=False) as step4:
|
| 114 |
gr.Markdown("**Inputs**: HEA and AL dataset. **Outputs**: HEA Knowledge Book and AL Knowledge Book.")
|
| 115 |
with gr.Row():
|
| 116 |
with gr.Column():
|
|
|
|
| 132 |
alk_button.click(lambda: show_knowledge("AL_knowledge2_0.txt"), inputs=None, outputs=[modal, modal_content])
|
| 133 |
|
| 134 |
|
| 135 |
+
with gr.Tab("Step 5. Update Knowledge Books (LLM)", interactive=False) as step5:
|
| 136 |
gr.Markdown("**Inputs**: HEA and AL dataset and Knowledge Books. **Outputs**: Updated HEA and AL Knowledge Books.")
|
| 137 |
gr.Markdown("**Evaluate Candidates**")
|
| 138 |
with gr.Row():
|
|
|
|
| 178 |
ual_buttons[i].click(lambda: show_knowledge(f"AL_knowledge2_{i+1}.txt"), inputs=None, outputs=[modal, modal_content])
|
| 179 |
|
| 180 |
|
| 181 |
+
with gr.Tab("Step 6: Predict Solutions (LLM)", interactive=False) as step6:
|
| 182 |
gr.Markdown("**Inputs**: Composited Dataset and Knowledge Books. **Outputs**: Predicted YS UTS Elongation values.")
|
| 183 |
predict_prompt = gr.Textbox(label="LLM Prompt Template to Update HEA Knowledge Book", value=PREDICT_PROMPT, lines = 6,
|
| 184 |
interactive=False, autoscroll=True)
|
|
|
|
| 189 |
|
| 190 |
optimized_data = gr.State(0)
|
| 191 |
|
| 192 |
+
hea_button.click(optimize_HEA_dataset, inputs=[optimized_data], outputs=[hea_optimized, optimized_data, merge_button], show_progress=True).then(lambda: gr.update(interactive=True), outputs=[step2])
|
| 193 |
+
al_button.click(optimize_AL_dataset, inputs=[optimized_data], outputs=[al_optimized, optimized_data, merge_button]).then(lambda: gr.update(interactive=True), outputs=[step3])
|
| 194 |
+
merge_button.click(merge_datasets, inputs=[hea_optimized, al_optimized], outputs=[merged_data, merged_data, merge_label]).then(lambda: tuple([gr.update(interactive=True), gr.update(interactive=True)]), outputs=[step4, gen_kbook_button])
|
| 195 |
gen_kbook_button.click(
|
| 196 |
generate_knowledge_book,
|
| 197 |
inputs=None,
|
| 198 |
outputs=[heak_button, alk_button, gen_kbook_label, gen_kbook],
|
| 199 |
+
).then(lambda: tuple([gr.update(interactive=True), gr.update(interactive=True)]), outputs=[step5, update_kbook_button])
|
| 200 |
+
update_kbook_button.click(evaluate_update_dataset, inputs=None, outputs=[output_text, *uhea_buttons, *ual_buttons]).then(lambda: tuple([gr.update(interactive=True), gr.update(interactive=True)]), outputs=[step6, predict_button])
|
| 201 |
predict_button.click(evaluate_merged_data, inputs=None, outputs=[predict_data, predict_data, predict_label])
|
| 202 |
|
| 203 |
if __name__ == "__main__":
|
| 204 |
+
demo.launch(favicon_path="./favicon.ico", allowed_paths=["./"])
|