| 155 | |
| 156 | |
| 157 | YOLOLossImpl::YOLOLossImpl(torch::Tensor anchors_, int num_classes_, int img_size_[], |
| 158 | float label_smooth_, torch::Device device_, bool normalize) { |
| 159 | this->anchors = anchors_; |
| 160 | this->num_anchors = anchors_.sizes()[0]; |
| 161 | this->num_classes = num_classes_; |
| 162 | this->bbox_attrs = 5 + num_classes; |
| 163 | memcpy(image_size, img_size_, 2 * sizeof(int)); |
| 164 | std::vector<int> feature_length_ = { int(image_size[0] / 32),int(image_size[0] / 16),int(image_size[0] / 8) }; |
| 165 | std::copy(feature_length_.begin(), feature_length_.end(), feature_length.begin()); |
| 166 | this->label_smooth = label_smooth_; |
| 167 | this->device = device_; |
| 168 | this->normalize = normalize; |
| 169 | } |
| 170 | |
| 171 | std::vector<torch::Tensor> YOLOLossImpl::forward(torch::Tensor input, std::vector<torch::Tensor> targets) |
| 172 | { |