ros2 / openrobotics_darknet_ros

ROS 2 interface to darknet, an open source neural network library.
Apache License 2.0
19 stars 13 forks source link

Query regarding /src/detector_network.cpp Line 86 #4

Closed VeCAD closed 3 years ago

VeCAD commented 4 years ago

I was trying to get this wrapper to work and was hitting "Invalid network, it expects no classes" error. https://github.com/ros2/openrobotics_darknet_ros/blob/be4fd04c0ea8fbed80b3549283701e16145422c6/src/detector_network.cpp#L86-L89

impl_->network_ is assigned to Darknet's load_network function. As I understand, the load_network doesn't pull class information. It only contains the network cfg and weights. So num_classes_int will be always 0, I think.

const int num_classes_int = impl_->class_names_.size() maybe? I think this also affects the do_nms_sort function subsequently in the same file.

https://github.com/ros2/openrobotics_darknet_ros/blob/be4fd04c0ea8fbed80b3549283701e16145422c6/src/detector_network.cpp#L137

EDIT: Anyway the network cfg file does contains classes=80 line, not sure why it still returns 0.

Found a similar issue here: https://github.com/pjreddie/darknet/issues/384. I think I will just use load_meta to pull the class info from coco.data

sloretz commented 3 years ago

As I understand, the load_network doesn't pull class information. It only contains the network cfg and weights.

Hmm, the examples seem to assume that it is. The yolo.c example only calls load_network() before accessing the number of classes on the last layer of the network. Is it possible that the network being loaded has a final layer that doesn't have any classes?

I'll leave this open for a bit, though it sounds like this might be a bug in Darknet.

sloretz commented 3 years ago

Closing as upstream issue