gabboud commited on
Commit
743042b
·
1 Parent(s): 85d1bb6

remove 3d visualization

Browse files
Files changed (3) hide show
  1. app.py +18 -19
  2. issues_doc.md +9 -0
  3. utils/pipelines.py +0 -1
app.py CHANGED
@@ -10,7 +10,7 @@ from lightning.fabric import seed_everything
10
  from rfd3.engine import RFD3InferenceConfig, RFD3InferenceEngine
11
  from utils import download_weights
12
  from utils.pipelines import test_rfd3_from_notebook, unconditional_generation
13
- from gradio_molecule3d import Molecule3D
14
 
15
 
16
  download_weights()
@@ -56,8 +56,6 @@ with gr.Blocks(title="RFD3 Test") as demo:
56
  gen_btn = gr.Button("Run Unconditional Generation")
57
 
58
 
59
-
60
-
61
  # New visualize section
62
  with gr.Row():
63
  batch_dropdown = gr.Dropdown(
@@ -73,8 +71,8 @@ with gr.Blocks(title="RFD3 Test") as demo:
73
  visualize_btn = gr.Button("Visualize", visible=True)
74
 
75
  display_state = gr.Textbox(label="Selected Batch and Design", visible=True)
76
- display_state.value = "Please Select a Batch and Design number to visualize."
77
- viewer = Molecule3D(visible=True)
78
 
79
  def update_batch_choices(result):
80
  if result is None:
@@ -89,7 +87,6 @@ with gr.Blocks(title="RFD3 Test") as demo:
89
 
90
 
91
 
92
-
93
  def update_designs(batch, result):
94
  if batch is None:
95
  return gr.update(choices=[])
@@ -101,23 +98,25 @@ with gr.Blocks(title="RFD3 Test") as demo:
101
  batch_dropdown.change(update_designs, inputs=[batch_dropdown, gen_results], outputs=[design_dropdown])
102
  design_dropdown.change()
103
 
104
- def visualize_selection(batch, design):
105
  if batch is None or design is None:
106
- return gr.update(value="**Please select both batch and design.**", visible=True)
107
- return gr.update(value=f"**Selected Batch: {batch}, Design: {design}**", visible=True)
108
-
109
-
110
-
111
- visualize_btn.click(visualize_selection, inputs=[batch_dropdown, design_dropdown], outputs=display_state)
112
 
 
 
113
 
114
- def load_viewer(batch, design, result):
115
- if batch is None or design is None:
116
- return gr.update()
117
- pdb_data = next(d["pdb"] for d in result if d["batch"] == int(batch) and d["design"] == int(design))
118
- return gr.update(value=pdb_data, visible=True, reps=[{"style": "cartoon"}]) # Customize style
119
 
120
- visualize_btn.click(load_viewer, inputs=[batch_dropdown, design_dropdown, gen_results], outputs=viewer)
 
 
 
 
 
 
121
 
122
  if __name__ == "__main__":
123
  demo.launch()
 
10
  from rfd3.engine import RFD3InferenceConfig, RFD3InferenceEngine
11
  from utils import download_weights
12
  from utils.pipelines import test_rfd3_from_notebook, unconditional_generation
13
+ #from gradio_molecule3d import Molecule3D
14
 
15
 
16
  download_weights()
 
56
  gen_btn = gr.Button("Run Unconditional Generation")
57
 
58
 
 
 
59
  # New visualize section
60
  with gr.Row():
61
  batch_dropdown = gr.Dropdown(
 
71
  visualize_btn = gr.Button("Visualize", visible=True)
72
 
73
  display_state = gr.Textbox(label="Selected Batch and Design", visible=True)
74
+ display_state.value = "Please Select a Batch and Design number to show sequence"
75
+ #viewer = Molecule3D(visible=True)
76
 
77
  def update_batch_choices(result):
78
  if result is None:
 
87
 
88
 
89
 
 
90
  def update_designs(batch, result):
91
  if batch is None:
92
  return gr.update(choices=[])
 
98
  batch_dropdown.change(update_designs, inputs=[batch_dropdown, gen_results], outputs=[design_dropdown])
99
  design_dropdown.change()
100
 
101
+ def visualize_selection(batch, design, result):
102
  if batch is None or design is None:
103
+ return gr.update()
104
+ pdb_path= next(d["pdb"] for d in result if d["batch"] == int(batch) and d["design"] == int(design))
105
+ with open(pdb_path, 'r') as f:
106
+ pdb_str = f.read()
107
+ return gr.update(value=f"Selected Batch: {batch}, Design: {design}, saved at {pdb_str}:\n {pdb_str}", visible=True)
 
108
 
109
+
110
+ visualize_btn.click(visualize_selection, inputs=[batch_dropdown, design_dropdown, gen_results], outputs=display_state)
111
 
 
 
 
 
 
112
 
113
+ #def load_viewer(batch, design, result):
114
+ # if batch is None or design is None:
115
+ # return gr.update()
116
+ # pdb_data = next(d["pdb"] for d in result if d["batch"] == int(batch) and d["design"] == int(design))
117
+ # return gr.update(value=pdb_data, visible=True, reps=[{"style": "cartoon"}]) # Customize style
118
+ #
119
+ #visualize_btn.click(load_viewer, inputs=[batch_dropdown, design_dropdown, gen_results], outputs=viewer)
120
 
121
  if __name__ == "__main__":
122
  demo.launch()
issues_doc.md CHANGED
@@ -1,6 +1,15 @@
 
 
 
1
  - I'm trying to make it so that pushing new code (editing app.py) and building again does not need to redownload the weights
2
  - In a space like BoltzGen, all the installation happens in requirements.txt. downloading Boltzgen downloads the weights. This means that when I push app.py code, HF detects that requirements.txt did not change, it pulls the built image from cache and there is no need for redownload
3
  - In my space, this is not the case, pip install rc-foundry is cached (from requirements.txt) but I need to run the command "foundry install rfd3 ligandmpnn rf3" to download the weights. I do the installation in the header of app.py. This means that the installation reruns every code push to app.py
4
  - I considered fixing this using Docker instead of Gradio as I could create a Docker image with the weights downloaded but Docker is not compatible with ZeroGPU, needed for the hackathon
5
  - I tried to use persistent storage using ./data to store the weights but persistent storage is only available at runtime not during build so I get a "Permission Denied" error.
6
  - This problem is annoying for development but not really once the space is done and is being used as there will be no more code pushes.
 
 
 
 
 
 
 
1
+
2
+ # Issue 1: redownloading model weights at every restart/ code upload
3
+
4
  - I'm trying to make it so that pushing new code (editing app.py) and building again does not need to redownload the weights
5
  - In a space like BoltzGen, all the installation happens in requirements.txt. downloading Boltzgen downloads the weights. This means that when I push app.py code, HF detects that requirements.txt did not change, it pulls the built image from cache and there is no need for redownload
6
  - In my space, this is not the case, pip install rc-foundry is cached (from requirements.txt) but I need to run the command "foundry install rfd3 ligandmpnn rf3" to download the weights. I do the installation in the header of app.py. This means that the installation reruns every code push to app.py
7
  - I considered fixing this using Docker instead of Gradio as I could create a Docker image with the weights downloaded but Docker is not compatible with ZeroGPU, needed for the hackathon
8
  - I tried to use persistent storage using ./data to store the weights but persistent storage is only available at runtime not during build so I get a "Permission Denied" error.
9
  - This problem is annoying for development but not really once the space is done and is being used as there will be no more code pushes.
10
+
11
+ # Issue 2: not able to integrate gradio_molecule3D to visualize outputs
12
+
13
+ - I wanted to visualize the output of RFD3 in a widget in the HF space. I got it to work on a minimal example with a custom pdb file (not using RFD3)
14
+ - once I tried to integrate the 2, it wouldnt work because gradio_molecule3d and rc-foundry require conflicting versions of gradio: gradio_molecule3d requires <6 while rc-foundry requires 6.5.1.
15
+ - pinning gradio version manually did not work, gradio_Model3D does not support PDB and I couldnt get py3Dmol working
utils/pipelines.py CHANGED
@@ -5,7 +5,6 @@ import time
5
  import os
6
  import spaces
7
  import subprocess
8
- from Bio.PDB import MMCIFParser, PDBIO
9
  import gzip
10
  import gemmi
11
 
 
5
  import os
6
  import spaces
7
  import subprocess
 
8
  import gzip
9
  import gemmi
10