gabboud commited on
Commit
b212ae4
·
1 Parent(s): a76c148

add support for extra args for rfdiffusion3

Browse files
Files changed (2) hide show
  1. app.py +12 -4
  2. utils/pipelines.py +3 -1
app.py CHANGED
@@ -65,7 +65,15 @@ with gr.Blocks(title="RFD3 Test") as demo:
65
 
66
  config_validation_btn = gr.Button("Validate Config")
67
  config_textbox = gr.Textbox(value ="Waiting for config validation...")
68
-
 
 
 
 
 
 
 
 
69
  with gr.Column(scale=1): # Right half
70
  gr.Markdown("Upload your target/scaffold structure as a PDB file to condition the generation. Press 'No Scaffold/Target' if you want to run an unconditional generation.")
71
  scaffold_upload = gr.File(label="Target/Scaffold PDB", file_types=[".pdb"])
@@ -102,17 +110,17 @@ with gr.Blocks(title="RFD3 Test") as demo:
102
  display_state = gr.Textbox(label="Selected Batch and Design", visible=True)
103
  display_state.value = "Please Select a Batch and Design number to show sequence"
104
 
105
- def generate(config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload):
106
  if config_ready is None or scaffold_ready is None:
107
  return None, None
108
  if config_ready == "upload" and scaffold_ready == "no_input":
109
- gen_directory, gen_results = unconditional_generation_with_input_config(config_upload, num_batches, num_designs_per_batch)
110
  return gen_directory, gen_results
111
  else:
112
  return None, None
113
 
114
  run_btn.click(give_run_status, inputs=[config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload], outputs=runtextbox).then(
115
- generate, inputs=[config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload], outputs=[gen_directory, gen_results]
116
  ).then(
117
  update_batch_choices,
118
  inputs=gen_results,
 
65
 
66
  config_validation_btn = gr.Button("Validate Config")
67
  config_textbox = gr.Textbox(value ="Waiting for config validation...")
68
+
69
+ with gr.Accordion(label="Advanced Options", open=False):
70
+ extra_args = gr.Textbox(
71
+ label="Additional CLI Arguments",
72
+ placeholder="e.g., inference_sampler.step_scale=3 inference_sampler.gamma_0=0.2",
73
+ lines=3,
74
+ info="Add extra RFD3 CLI arguments here (optional)"
75
+ )
76
+
77
  with gr.Column(scale=1): # Right half
78
  gr.Markdown("Upload your target/scaffold structure as a PDB file to condition the generation. Press 'No Scaffold/Target' if you want to run an unconditional generation.")
79
  scaffold_upload = gr.File(label="Target/Scaffold PDB", file_types=[".pdb"])
 
110
  display_state = gr.Textbox(label="Selected Batch and Design", visible=True)
111
  display_state.value = "Please Select a Batch and Design number to show sequence"
112
 
113
+ def generate(config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload, extra_args):
114
  if config_ready is None or scaffold_ready is None:
115
  return None, None
116
  if config_ready == "upload" and scaffold_ready == "no_input":
117
+ gen_directory, gen_results = unconditional_generation_with_input_config(config_upload, num_batches, num_designs_per_batch, extra_args)
118
  return gen_directory, gen_results
119
  else:
120
  return None, None
121
 
122
  run_btn.click(give_run_status, inputs=[config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload], outputs=runtextbox).then(
123
+ generate, inputs=[config_ready, scaffold_ready, num_batches, num_designs_per_batch, config_upload, extra_args], outputs=[gen_directory, gen_results]
124
  ).then(
125
  update_batch_choices,
126
  inputs=gen_results,
utils/pipelines.py CHANGED
@@ -99,7 +99,7 @@ def unconditional_generation(num_batches, num_designs_per_batch, length):
99
  raise RuntimeError(f"Error during generation: {str(e)}")
100
 
101
  @spaces.GPU(duration=300)
102
- def unconditional_generation_with_input_config(input_file, num_batches, num_designs_per_batch):
103
  """
104
  Runs an unconditional generation with the specified input config file. Saves the generated structures to a timestamped directory in the outputs folder and returns the path to the directory along with a list of the generated structures' file paths.
105
 
@@ -125,6 +125,8 @@ def unconditional_generation_with_input_config(input_file, num_batches, num_desi
125
  try:
126
 
127
  command = f"rfd3 design inputs={input_file} out_dir={directory} n_batches={num_batches} diffusion_batch_size={num_designs_per_batch}"
 
 
128
  print(f"Running command: {command}")
129
  subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
130
 
 
99
  raise RuntimeError(f"Error during generation: {str(e)}")
100
 
101
  @spaces.GPU(duration=300)
102
+ def unconditional_generation_with_input_config(input_file, num_batches, num_designs_per_batch, extra_args):
103
  """
104
  Runs an unconditional generation with the specified input config file. Saves the generated structures to a timestamped directory in the outputs folder and returns the path to the directory along with a list of the generated structures' file paths.
105
 
 
125
  try:
126
 
127
  command = f"rfd3 design inputs={input_file} out_dir={directory} n_batches={num_batches} diffusion_batch_size={num_designs_per_batch}"
128
+ if extra_args:
129
+ command += f" {extra_args}"
130
  print(f"Running command: {command}")
131
  subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
132