ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.23k stars 3.45k forks source link

yolov3_ros input topic channel problem #2195

Closed imdsafi09 closed 7 months ago

imdsafi09 commented 9 months ago

Search before asking

Question

Hello, I am attempting to utilize darknet_ros with ouster lidar (OS-128) signal images. It works well with yolov5, yolov7, and v8. However, when I attempt to run it with yolov3, I receive a warning that says, "[ WARN] [1707979926.073420346]: Converting mono16 images to mono8," followed by a failure. Could you kindly provide a possible solution? Screenshot from 2024-02-15 15-54-01

Additional

No response

github-actions[bot] commented 9 months ago

👋 Hello @imdsafi09, thank you for your interest in YOLOv3 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov3  # clone
cd yolov3
pip install -r requirements.txt  # install

Environments

YOLOv3 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv3 CI

If this badge is green, all YOLOv3 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv3 training, validation, inference, export and benchmarks on macOS, Windows, and Ubuntu every 24 hours and on every commit.

Introducing YOLOv8 🚀

We're excited to announce the launch of our latest state-of-the-art (SOTA) object detection model for 2023 - YOLOv8 🚀!

Designed to be fast, accurate, and easy to use, YOLOv8 is an ideal choice for a wide range of object detection, image segmentation and image classification tasks. With YOLOv8, you'll be able to quickly and accurately detect objects in real-time, streamline your workflows, and achieve new levels of accuracy in your projects.

Check out our YOLOv8 Docs for details and get started with:

pip install ultralytics
glenn-jocher commented 9 months ago

@imdsafi09 hello!

It sounds like you're experiencing an issue with image encoding compatibility when using YOLOv3 with ROS and your Ouster lidar's mono16 images. YOLOv3 typically expects 8-bit images (mono8 or bgr8), so the warning indicates that ROS is trying to convert from mono16 to mono8 to match the expected input format.

To address this, you could manually convert your images to mono8 or bgr8 before passing them to YOLOv3. This conversion can be done within your ROS node that interfaces with the YOLOv3 model. You might need to adjust the image encoding in your subscriber callback function to ensure the images are in the correct format before they are processed by YOLOv3.

For more detailed guidance on working with different image encodings and YOLOv3, please refer to our documentation at https://docs.ultralytics.com.

Keep in mind that handling image data correctly is crucial for the performance of the model. If the issue persists after trying the suggested conversion, please provide more details about the error message following the warning, and we'll do our best to assist you further.

imdsafi09 commented 9 months ago

@glenn-jocher Hello! Thank you for your detailed answer. I tried to write a python script to convert mono-16 to mono-8, and after checking in ROS rqt it seems the coversion is working. However, the error remain persist. Below I attached the code please let me if there is any issue in that.

`#!/usr/bin/env python3

import rospy from sensor_msgs.msg import Image import cv2 from cv_bridge import CvBridge, CvBridgeError

class ImageConverter: def init(self): self.bridge = CvBridge() self.image_sub = rospy.Subscriber("/ouster/signal_image", Image, self.callback) self.image_pub = rospy.Publisher("ouster/rgb/image_raw", Image, queue_size=10)

def callback(self, data):
    try:
        # Convert the ROS image to a CV2 image
        cv_image = self.bridge.imgmsg_to_cv2(data, "mono16")
    except CvBridgeError as e:
        rospy.logerr(e)

    # Perform the conversion from Mono16 to Mono8
    # OpenCV automatically scales the pixel values to the 0-255 range
    cv_image_mono8 = cv2.convertScaleAbs(cv_image, alpha=(255.0/65535.0))

    try:
        # Convert the CV2 image back to a ROS image and publish
        self.image_pub.publish(self.bridge.cv2_to_imgmsg(cv_image_mono8, "mono8"))
    except CvBridgeError as e:
        rospy.logerr(e)

if name == 'main': rospy.init_node('mono16_to_mono8_converter', anonymous=True) ic = ImageConverter() try: rospy.spin() except KeyboardInterrupt: print("Shutting down") `

glenn-jocher commented 9 months ago

@imdsafi09, your script for converting mono16 to mono8 images looks correct at a glance. The conversion logic and the use of cv_bridge for ROS and OpenCV image conversions are appropriate.

If the error persists, it might not be related to the image conversion itself. Here are a few things to check:

  1. Ensure that the topic ouster/rgb/image_raw is correctly subscribed to by the YOLOv3 node.
  2. Verify that the images published on ouster/rgb/image_raw are visible and correctly formatted in rqt_image_view.
  3. Check if there are any additional error messages or logs from the YOLOv3 node that could provide more insight into the failure.
  4. Confirm that the YOLOv3 model is correctly loaded and configured to process mono8 images.

If everything seems to be in order with the image conversion and publishing, the issue might lie within the YOLOv3 ROS node's configuration or its handling of the incoming image messages. Double-check the YOLOv3 ROS node's documentation and ensure that all necessary parameters are set correctly.

If you continue to face difficulties, please provide the exact error message you're receiving from the YOLOv3 node after the conversion, and we'll try to troubleshoot further. Remember, the more specific the information you provide, the easier it will be to pinpoint the issue.

github-actions[bot] commented 8 months ago

👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help.

For additional resources and information, please see the links below:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLO 🚀 and Vision AI ⭐