Skip to content

Commit e7ac2ec

Browse files
committed
Fix vision.h import not found
1 parent 0eb8ee0 commit e7ac2ec

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

fcos/bin/fcos

+26-25
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,37 @@ def pretty_print(bbox_results):
2323
))
2424

2525

26-
parser = argparse.ArgumentParser(description="FCOS Object Detector")
27-
parser.add_argument(
28-
"input_image",
29-
help="path or url to an input image",
30-
)
31-
args = parser.parse_args()
26+
if __name__ == "__main__":
27+
parser = argparse.ArgumentParser(description="FCOS Object Detector")
28+
parser.add_argument(
29+
"input_image",
30+
help="path or url to an input image",
31+
)
32+
args = parser.parse_args()
3233

33-
fcos = FCOS(
34-
model_name="fcos_syncbn_bs32_c128_MNV2_FPN_1x",
35-
nms_thresh=0.6,
36-
cpu_only=not torch.cuda.is_available() # if you do not have GPUs, please set cpu_only as True
37-
)
34+
fcos = FCOS(
35+
model_name="fcos_syncbn_bs32_c128_MNV2_FPN_1x",
36+
nms_thresh=0.6,
37+
cpu_only=not torch.cuda.is_available() # if you do not have GPUs, please set cpu_only as True
38+
)
3839

39-
im = io.imread(args.input_image)
40-
assert im.shape[-1] == 3, "only 3-channel images are supported"
40+
im = io.imread(args.input_image)
41+
assert im.shape[-1] == 3, "only 3-channel images are supported"
4142

42-
# convert from RGB to BGR because fcos assumes the BRG input image
43-
im = im[..., ::-1].copy()
43+
# convert from RGB to BGR because fcos assumes the BRG input image
44+
im = im[..., ::-1].copy()
4445

45-
# resize image to have its shorter size == 800
46-
f = 800.0 / float(min(im.shape[:2]))
47-
im = cv2.resize(im, (0, 0), fx=f, fy=f)
46+
# resize image to have its shorter size == 800
47+
f = 800.0 / float(min(im.shape[:2]))
48+
im = cv2.resize(im, (0, 0), fx=f, fy=f)
4849

49-
start_time = time.time()
50+
start_time = time.time()
5051

51-
bbox_results = fcos.detect(im)
52+
bbox_results = fcos.detect(im)
5253

53-
inference_time = time.time() - start_time
54+
inference_time = time.time() - start_time
5455

55-
pretty_print(bbox_results)
56-
print("Predicted in {:.2f} seconds.".format(inference_time))
57-
print("Press any key to exit...")
58-
fcos.show_bboxes(im, bbox_results)
56+
pretty_print(bbox_results)
57+
print("Predicted in {:.2f} seconds.".format(inference_time))
58+
print("Press any key to exit...")
59+
fcos.show_bboxes(im, bbox_results)

0 commit comments

Comments
 (0)