Skip to content

Commit

Permalink
Merge pull request #73 from swalehmwadime/master
Browse files Browse the repository at this point in the history
Syntax Error-fix
  • Loading branch information
wondervictor authored Mar 1, 2024
2 parents bd9cd3a + e24d841 commit 8b998c9
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions image_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
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
from mmengine.dataset import Compose
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')
Expand All @@ -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,
Expand Down Expand Up @@ -88,9 +88,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
Expand Down Expand Up @@ -131,7 +129,7 @@ def inference_detector(runner,


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
Expand Down

0 comments on commit 8b998c9

Please sign in to comment.