mgyigit commited on
Commit
f87af8c
1 Parent(s): 78c3224

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +6 -5
gradio_app.py CHANGED
@@ -8,6 +8,7 @@ from rdkit import Chem
8
  from rdkit.Chem import Draw
9
  from rdkit.Chem.Draw import IPythonConsole
10
  import shutil
 
11
 
12
  class DrugGENConfig:
13
  submodel='DrugGEN'
@@ -52,15 +53,15 @@ def function(model_name: str, num_molecules: int, seed_num: int) -> tuple[PIL.Im
52
  config = model_configs[model_name]
53
  config.sample_num = num_molecules
54
 
55
- print(seed_num)
56
  if seed_num is not None:
57
  try:
58
  config.seed = int(seed_num)
59
- except:
60
- raise Exception("The seed must be an integer value!")
61
  else:
62
  config.seed = random.randint(0, 10000)
63
 
 
64
  inferer = Inference(config)
65
  scores = inferer.inference() # create scores_df out of this
66
 
@@ -68,7 +69,6 @@ def function(model_name: str, num_molecules: int, seed_num: int) -> tuple[PIL.Im
68
 
69
  output_file_path = f'experiments/inference/{model_name}/inference_drugs.txt'
70
 
71
- import os
72
  new_path = f'{model_name}_denovo_mols.smi'
73
  os.rename(output_file_path, new_path)
74
 
@@ -135,7 +135,8 @@ with gr.Blocks() as demo:
135
  )
136
 
137
  seed_num = gr.Textbox(
138
- label="RNG seed value (can be used for reproducibility):"
 
139
  )
140
 
141
  submit_button = gr.Button(
 
8
  from rdkit.Chem import Draw
9
  from rdkit.Chem.Draw import IPythonConsole
10
  import shutil
11
+ import os
12
 
13
  class DrugGENConfig:
14
  submodel='DrugGEN'
 
53
  config = model_configs[model_name]
54
  config.sample_num = num_molecules
55
 
 
56
  if seed_num is not None:
57
  try:
58
  config.seed = int(seed_num)
59
+ except ValueError:
60
+ raise gr.Warning("The seed must be an integer value!")
61
  else:
62
  config.seed = random.randint(0, 10000)
63
 
64
+
65
  inferer = Inference(config)
66
  scores = inferer.inference() # create scores_df out of this
67
 
 
69
 
70
  output_file_path = f'experiments/inference/{model_name}/inference_drugs.txt'
71
 
 
72
  new_path = f'{model_name}_denovo_mols.smi'
73
  os.rename(output_file_path, new_path)
74
 
 
135
  )
136
 
137
  seed_num = gr.Textbox(
138
+ label="RNG seed value (can be used for reproducibility):",
139
+ value=None
140
  )
141
 
142
  submit_button = gr.Button(