-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetect.py
21 lines (16 loc) · 1.06 KB
/
detect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from argparse import ArgumentParser
from detection import PromptOWLViT
def parse_arguments():
"""Returns parsed arguments"""
parser = ArgumentParser(description="Detects bounding boxes for given image and text prompts")
parser.add_argument("image_name", type=str, default=None,
help="Name of the image file that be processed. Note image file must be in 'detection-images' directory")
parser.add_argument("text_prompts", nargs="+", type=str, default=None, help="Text prompts for the model")
parser.add_argument("--image_size", nargs="+", type=int, default=None,
help="Size (width, height) to which the image be transformed. Default: None")
parser.add_argument("--device", type=str, default="cpu", help="Device that be used during inference. Default: 'cpu'")
return parser.parse_args()
if __name__ == "__main__":
args = parse_arguments()
print("Provided text prompts:", args.text_prompts)
PromptOWLViT(args.image_name, device=args.device).detect(args.text_prompts, args.image_size, save=True)