wenhao-gao commited on
Commit ·
df75420
1
Parent(s): 1b7c1ca
update
Browse files
app.py
CHANGED
|
@@ -17,7 +17,7 @@ last_result = {}
|
|
| 17 |
# Function to clear all inputs
|
| 18 |
def clear_inputs():
|
| 19 |
# Return default or empty values to reset each input component
|
| 20 |
-
return None,
|
| 21 |
|
| 22 |
def sample(smi, search_width, exhaustiveness):
|
| 23 |
result_df = run_sampling_one_cpu(
|
|
@@ -45,9 +45,9 @@ def select_from_output(index):
|
|
| 45 |
return df_results.iloc[index]["smiles"], df_results.iloc[index]["score"], df_results.iloc[index]["synthesis"]
|
| 46 |
|
| 47 |
examples = [
|
|
|
|
| 48 |
"Nc1cccc(S(=O)(=O)N2CCCN(S(=O)(=O)c3ccc4c(c3)OCCO4)CC2)c1",
|
| 49 |
"CN1C[C@H](Nc2cnn(C)c(=O)c2)C[C@H](c2ccccc2)C1",
|
| 50 |
-
"COc1ccc(-c2ccnc(Nc3ccccc3)n2)cc1",
|
| 51 |
"CC[C@@H]1OC[C@@]23Cc4cc(F)c(N)cc4-c4ccc5c(c42)C(=CC(F)(F)O5)[C@@H]1C3=O",
|
| 52 |
"O=C(OCC(=O)N1[C@H](C(=O)O)C[C@@H]2CCCC[C@@H]21)[C@H](Cc1cbccc1)NC(I)c1bcccc1",
|
| 53 |
]
|
|
@@ -57,9 +57,10 @@ with gr.Blocks() as demo:
|
|
| 57 |
gr.Markdown(f"""
|
| 58 |
# Demo of [SynFormer](https://github.com/wenhao-gao/synformer/tree/main)
|
| 59 |
This page demonstrates the SynFormer-ED model, which takes a molecule as input—regardless of its synthetic accessibility—and outputs
|
| 60 |
-
identical or approximate molecules along with their associated synthetic paths.
|
| 61 |
-
one minute per run on local machine, but can be accelerated by reducing the
|
| 62 |
-
|
|
|
|
| 63 |
30 molecules displayed at once.
|
| 64 |
To learn more about SynFormer’s architecture and applications, check out [our paper](https://github.com/wenhao-gao/synformer/tree/main).
|
| 65 |
|
|
@@ -68,8 +69,8 @@ with gr.Blocks() as demo:
|
|
| 68 |
with gr.Row():
|
| 69 |
with gr.Column(scale=0.5):
|
| 70 |
input_molecule = molecule2d(label="SMILES Input")
|
| 71 |
-
slider_1 = gr.Slider(minimum=1, maximum=
|
| 72 |
-
slider_2 = gr.Slider(minimum=1, maximum=
|
| 73 |
|
| 74 |
with gr.Row():
|
| 75 |
with gr.Column(scale=0.5):
|
|
|
|
| 17 |
# Function to clear all inputs
|
| 18 |
def clear_inputs():
|
| 19 |
# Return default or empty values to reset each input component
|
| 20 |
+
return None, 4, 8, 0
|
| 21 |
|
| 22 |
def sample(smi, search_width, exhaustiveness):
|
| 23 |
result_df = run_sampling_one_cpu(
|
|
|
|
| 45 |
return df_results.iloc[index]["smiles"], df_results.iloc[index]["score"], df_results.iloc[index]["synthesis"]
|
| 46 |
|
| 47 |
examples = [
|
| 48 |
+
"COc1ccc(-c2ccnc(Nc3ccccc3)n2)cc1",
|
| 49 |
"Nc1cccc(S(=O)(=O)N2CCCN(S(=O)(=O)c3ccc4c(c3)OCCO4)CC2)c1",
|
| 50 |
"CN1C[C@H](Nc2cnn(C)c(=O)c2)C[C@H](c2ccccc2)C1",
|
|
|
|
| 51 |
"CC[C@@H]1OC[C@@]23Cc4cc(F)c(N)cc4-c4ccc5c(c42)C(=CC(F)(F)O5)[C@@H]1C3=O",
|
| 52 |
"O=C(OCC(=O)N1[C@H](C(=O)O)C[C@@H]2CCCC[C@@H]21)[C@H](Cc1cbccc1)NC(I)c1bcccc1",
|
| 53 |
]
|
|
|
|
| 57 |
gr.Markdown(f"""
|
| 58 |
# Demo of [SynFormer](https://github.com/wenhao-gao/synformer/tree/main)
|
| 59 |
This page demonstrates the SynFormer-ED model, which takes a molecule as input—regardless of its synthetic accessibility—and outputs
|
| 60 |
+
identical or approximate molecules along with their associated synthetic paths.
|
| 61 |
+
This demo runs on CPUs and typically takes about one minute per run on local machine, but can be accelerated by reducing the
|
| 62 |
+
search width and exhaustiveness. The model may take longer if the server is busy.
|
| 63 |
+
Since the sampling is stochastic, you may run the demo multiple times to explore different results, with a maximum of
|
| 64 |
30 molecules displayed at once.
|
| 65 |
To learn more about SynFormer’s architecture and applications, check out [our paper](https://github.com/wenhao-gao/synformer/tree/main).
|
| 66 |
|
|
|
|
| 69 |
with gr.Row():
|
| 70 |
with gr.Column(scale=0.5):
|
| 71 |
input_molecule = molecule2d(label="SMILES Input")
|
| 72 |
+
slider_1 = gr.Slider(minimum=1, maximum=16, step=1, label="Search Width", value=4)
|
| 73 |
+
slider_2 = gr.Slider(minimum=1, maximum=32, step=1, label="Exhaustiveness", value=8)
|
| 74 |
|
| 75 |
with gr.Row():
|
| 76 |
with gr.Column(scale=0.5):
|