Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax Error-fix #73

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Expand All @@ -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
Expand Down