-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_hub.py
43 lines (29 loc) · 1006 Bytes
/
example_hub.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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import torch
import cv2, torch
import argparse
import numpy as np
im_path = './assets/notredame.jpg'
def parseArg():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input", help="input image"
, default=im_path)
args = parser.parse_args()
return args
# main
if __name__ == "__main__":
args = parseArg()
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
img = cv2.imread(args.input)
detector = torch.hub.load("verlab/LearningToDetect_PRL_2023:main", "Detector", pretrained=True, force_reload=True)
detector.to(device)
detector.eval()
print(f"Img shape: {img.shape}")
keypoints, score_map = detector.detect(img, 1024)
print("Score Map:", score_map.shape)
print("Keypoints:", keypoints.shape)
import pdb; pdb.set_trace()
# plot keypoints
for kp in keypoints:
cv2.circle(img, (int(kp[0]), int(kp[1])), 3, (255, 0, 0), -1)
cv2.imwrite("output.png", img)
print("Done!")