Spaces:
Running on Zero
Running on Zero
minimal test
Browse files- app.py +68 -0
- requiremements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
import os
|
| 4 |
+
import subprocess
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import shutil
|
| 7 |
+
import spaces
|
| 8 |
+
|
| 9 |
+
# Download model weights (skips already-downloaded models automatically)
|
| 10 |
+
# In total, ~6GB (3GB for RFD3, 3GB for RF3, <100MB for MPNN); may take a few minutes depending on your connection speed
|
| 11 |
+
os.system("foundry install rfd3 ligandmpnn rf3")# installing model weights
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
#download_dir = "./models/"
|
| 15 |
+
#if not os.path.exists(download_dir):
|
| 16 |
+
# cmd = "foundry install rfd3 ligandmpnn rf3"
|
| 17 |
+
# result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
| 18 |
+
#
|
| 19 |
+
## Run once on startup: Install models if missing
|
| 20 |
+
#checkpoint_dir = Path.home() / ".foundry" / "checkpoints"
|
| 21 |
+
#os.environ["FOUNDRY_CHECKPOINT_DIRS"] = str(checkpoint_dir)
|
| 22 |
+
#
|
| 23 |
+
#def install_models():
|
| 24 |
+
# """Download rfd3, ligandmpnn, rf3 weights once."""
|
| 25 |
+
# #models = ["rfd3", "ligandmpnn", "rf3"]
|
| 26 |
+
# models = ["ligandmpnn"] # let's start with only ligand mpnn for testing
|
| 27 |
+
# for model in models:
|
| 28 |
+
# if not (checkpoint_dir / model).exists():
|
| 29 |
+
# print(f"Installing {model}...")
|
| 30 |
+
# subprocess.check_call(["foundry", "install", model])
|
| 31 |
+
# print("All models installed.")
|
| 32 |
+
#
|
| 33 |
+
#install_models() # Executes on app.py load
|
| 34 |
+
|
| 35 |
+
@spaces.GPU(duration=300)
|
| 36 |
+
def test_rfd3():
|
| 37 |
+
"""Run a quick rfd3 test design (minimal monomer, 1 step)."""
|
| 38 |
+
try:
|
| 39 |
+
cmd = [
|
| 40 |
+
"rfd3",
|
| 41 |
+
"design",
|
| 42 |
+
"--seed", "42",
|
| 43 |
+
"contigmap.contigs=[A10]", # Tiny 10-res monomer
|
| 44 |
+
"--num_designs", "1",
|
| 45 |
+
"inference.output_prefix=test_output",
|
| 46 |
+
"--inference.num_diffusion_steps", "10" # Fast test
|
| 47 |
+
]
|
| 48 |
+
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
| 49 |
+
if result.returncode == 0:
|
| 50 |
+
return "RFD3 test passed! Check test_output.pdb. Logs:\n" + result.stdout[-500:]
|
| 51 |
+
else:
|
| 52 |
+
return f"RFD3 test failed: {result.stderr}"
|
| 53 |
+
except Exception as e:
|
| 54 |
+
return f"Error: {str(e)}"
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
# Gradio UI
|
| 58 |
+
with gr.Blocks(title="RFD3 Test") as demo:
|
| 59 |
+
gr.Markdown("# RFdiffusion3 (RFD3) Model Checker")
|
| 60 |
+
gr.Markdown("Models auto-downloaded on launch. Click to test.")
|
| 61 |
+
|
| 62 |
+
test_btn = gr.Button("Run RFD3 Test")
|
| 63 |
+
output = gr.Textbox(label="Test Result")
|
| 64 |
+
|
| 65 |
+
test_btn.click(test_rfd3, outputs=output)
|
| 66 |
+
|
| 67 |
+
if __name__ == "__main__":
|
| 68 |
+
demo.launch()
|
requiremements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
pip install rc-foundry[all]
|