forked from mianqiu00/MuCO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackbone_sample.py
More file actions
executable file
·65 lines (54 loc) · 2.23 KB
/
backbone_sample.py
File metadata and controls
executable file
·65 lines (54 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import argparse
import logging
from omegaconf import OmegaConf
from runner.backbone_sampler import BackboneSampler
import os
from utils import seed_everything, pdb_to_pickle
import warnings
warnings.filterwarnings("ignore", message="The PyTorch API of nested tensors")
def main():
seed_everything()
parser = argparse.ArgumentParser()
parser.add_argument("--config_timestamp", type=str, default="2025-12-03_12-52-37", help="Path to config.yaml")
parser.add_argument("--ckpt_epoch", type=int, default=100, help="Path to model checkpoint.pth")
parser.add_argument("--output", type=str, default="./data/inference/pdb/coarse", help="Output directory")
parser.add_argument("--device", type=int, default=0, help="GPU device ID")
parser.add_argument("--batch_size", type=int, default=1024, help="Override batch size")
parser.add_argument("--sample", type=bool, default=False)
parser.add_argument("--split", type=str, default="CPBind")
args = parser.parse_args()
# Logging Setup
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s"
)
# Load Config
conf_path = os.path.join("./saved_model", args.config_timestamp, "config.yaml")
conf = OmegaConf.load(conf_path)
# Optional: Override config values via CLI
if args.batch_size:
conf.experiment.eval_batch_size = args.batch_size
if args.split:
conf.data.split = args.split
split = conf.data.split
output_path_pdb = args.output + "_" + split
if not os.path.exists(output_path_pdb):
os.makedirs(output_path_pdb, exist_ok=True)
# Initialize and Run
runner = BackboneSampler(
conf=conf,
ckpt_epoch=args.ckpt_epoch,
output_dir=output_path_pdb,
device_id=args.device,
is_sample=args.sample,
batch_size=args.batch_size
)
runner.run_batch_inference()
else:
print("Output path already exists. Skipping inference.")
output_path_pkl = output_path_pdb.replace("pdb", "pkl")
if not os.path.exists(output_path_pkl):
os.makedirs(output_path_pkl, exist_ok=True)
pdb_to_pickle(output_path_pdb, output_path_pkl)
if __name__ == "__main__":
main()