Skip to content

YOLOv7 Demo flips the Red and Blue channels on inference #323

Description

@elijah-utopia

The Video class that reads from a variety of image sources and returns "regular OpenCV frames" seems to return frames in the BGR format when the model autoshape function interprets at RGB frames.

It seems the expected behavior for python autoshape is that cv images are meant to have their channels already flipped
https://github.com/ultralytics/yolov5/blob/30e4c4f09297b67afedf8b2bcd851833ddc9dead/models/common.py#L243-L252

This is a model trained to recognize red rovers as targets and blue rovers as allies
trained model with test images
This is what happens with the yolov7 norfair tracker demo
not working
This is what happens with the demo modified with reversing the channels

        yolo_detections = model(
            frame[:,:,::-1], # convert from cv format BGR to np format RGB
            conf_threshold=args.conf_threshold,
            iou_threshold=args.iou_threshold,
            image_size=args.img_size,
            classes=args.classes,
        )

working, with flip

Environment :

  • OS: Ubuntu 20.04
  • Python version: 3.8.10
  • Norfair version: commit 009a1b1 (master branch as of July 5, 2024)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions