mgyigit commited on
Commit
14b9a92
1 Parent(s): a6f835f

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +3 -5
gradio_app.py CHANGED
@@ -51,7 +51,7 @@ def function(model_name: str, num_molecules: int, seed_num: int) -> tuple[PIL.Im
51
 
52
  config = model_configs[model_name]
53
  config.sample_num = num_molecules
54
- config.seed = seed_num
55
 
56
  inferer = Inference(config)
57
  scores = inferer.inference() # create scores_df out of this
@@ -67,13 +67,13 @@ def function(model_name: str, num_molecules: int, seed_num: int) -> tuple[PIL.Im
67
  with open(new_path) as f:
68
  inference_drugs = f.read()
69
 
70
- generated_molecule_list = inference_drugs.split("\n")
71
 
72
  rng = random.Random(config.seed)
73
  if num_molecules > 12:
74
  selected_molecules = rng.choices(generated_molecule_list, k=12)
75
  else:
76
- selected_molecules = rng.choices(generated_molecule_list, k=num_molecules)
77
 
78
  selected_molecules = [Chem.MolFromSmiles(mol) for mol in selected_molecules if Chem.MolFromSmiles(mol) is not None]
79
 
@@ -126,12 +126,10 @@ with gr.Blocks() as demo:
126
  maximum=10_000,
127
  )
128
 
129
- val = random.randint(0, 10000)
130
  seed_num = gr.Number(
131
  label="RNG seed value (can be used for reproducibility):",
132
  precision=0, # integer input
133
  minimum=0,
134
- value=val,
135
  )
136
 
137
  submit_button = gr.Button(
 
51
 
52
  config = model_configs[model_name]
53
  config.sample_num = num_molecules
54
+ config.seed = random.randint(0, 10000)
55
 
56
  inferer = Inference(config)
57
  scores = inferer.inference() # create scores_df out of this
 
67
  with open(new_path) as f:
68
  inference_drugs = f.read()
69
 
70
+ generated_molecule_list = inference_drugs.split("\n")[:-1]
71
 
72
  rng = random.Random(config.seed)
73
  if num_molecules > 12:
74
  selected_molecules = rng.choices(generated_molecule_list, k=12)
75
  else:
76
+ selected_molecules = generated_molecule_list
77
 
78
  selected_molecules = [Chem.MolFromSmiles(mol) for mol in selected_molecules if Chem.MolFromSmiles(mol) is not None]
79
 
 
126
  maximum=10_000,
127
  )
128
 
 
129
  seed_num = gr.Number(
130
  label="RNG seed value (can be used for reproducibility):",
131
  precision=0, # integer input
132
  minimum=0,
 
133
  )
134
 
135
  submit_button = gr.Button(