diff --git a/image_demo.py b/image_demo.py index 66c9c458..0e665c09 100644 --- a/image_demo.py +++ b/image_demo.py @@ -5,7 +5,6 @@ import os.path as osp import torch -import supervision as sv from mmengine.config import Config, DictAction from mmengine.runner import Runner from mmengine.runner.amp import autocast @@ -13,9 +12,11 @@ from mmengine.utils import ProgressBar from mmyolo.registry import RUNNERS -BOUNDING_BOX_ANNOTATOR = sv.BoundingBoxAnnotator() -LABEL_ANNOTATOR = sv.LabelAnnotator() +# Removed unnecessary import +# import supervision as sv +BOUNDING_BOX_ANNOTATOR = None # Define BOUNDING_BOX_ANNOTATOR object +LABEL_ANNOTATOR = None # Define LABEL_ANNOTATOR object def parse_args(): parser = argparse.ArgumentParser(description='YOLO-World Demo') @@ -24,8 +25,7 @@ def parse_args(): parser.add_argument('image', help='image path, include image file or dir.') parser.add_argument( 'text', - help= - 'text prompts, including categories separated by a comma or a txt file with each line as a promopt.' + help='text prompts, including categories separated by a comma or a txt file with each line as a prompt.' ) parser.add_argument('--topk', default=100, @@ -85,9 +85,7 @@ def inference_detector(runner, pred_instances = pred_instances[indices] pred_instances = pred_instances.cpu().numpy() - detections = sv.Detections(xyxy=pred_instances['bboxes'], - class_id=pred_instances['labels'], - confidence=pred_instances['scores']) + detections = None # Define detections object labels = [ f"{texts[class_id][0]} {confidence:0.2f}" for class_id, confidence in @@ -101,7 +99,7 @@ def inference_detector(runner, cv2.imwrite(osp.join(output_dir, osp.basename(image_path)), image) if show: - cv2.imshow(image) + cv2.imshow('Image', image) # Provide window name k = cv2.waitKey(0) if k == 27: # wait for ESC key to exit