forked from thomas0809/MolScribe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
predict.py
executable file
·24 lines (20 loc) · 898 Bytes
/
predict.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import argparse
import json
import torch
from molscribe import MolScribe
import warnings
warnings.filterwarnings('ignore')
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--model_path', type=str, default=None, required=True)
parser.add_argument('--image_path', type=str, default=None, required=True)
parser.add_argument('--return_confidence', action='store_true')
parser.add_argument('--return_atoms_bonds', action='store_true')
args = parser.parse_args()
device = torch.device('cuda')
model = MolScribe(args.model_path, device)
output = model.predict_image_file(
args.image_path, return_atoms_bonds=args.return_atoms_bonds, return_confidence=args.return_confidence)
for key, value in output.items():
print(f"{key}:")
print(value + '\n' if isinstance(value, str) else json.dumps(value) + '\n')