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

[!HOTFIX] yolov9 #597

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Add instance number logging feature for detection task by `@hglee98` in [PR 577](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/577)
- Add Precision and Recall metric for detection task by `@hglee98` in [PR 579](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/579)
- Add YOLOv9 by `@hglee98` in [PR 585](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/585), [PR 586](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/586), [PR 592](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/592), [PR 593](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/593), [PR 595](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/595), [PR 589](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/589), [PR 590](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/590)
- Add YOLOv9 by `@hglee98` in [PR 585](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/585), [PR 586](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/586), [PR 592](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/592), [PR 593](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/593), [PR 595](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/595), [PR 589](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/589), [PR 590](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/590), [PR 597](https://github.com/Nota-NetsPresso/netspresso-trainer/pull/597)

## Bug Fixes:

Expand Down
3 changes: 2 additions & 1 deletion src/netspresso_trainer/models/op/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,7 @@ def forward(self, x: Union[Tensor, Proxy]) -> Union[Tensor, Proxy]:
batch_size, channel_size, height, width = x.shape
reg_channel = channel_size // 4
predictions = 4 # Number of predictions per anchor
anchor_x = x.view(batch_size, reg_channel, predictions, height, width)
anchor_x = x.view(batch_size, predictions, reg_channel, height, width)
anchor_x = anchor_x.permute(0, 2, 1, 3, 4)
vector_x = self.anchor2vec(anchor_x.softmax(dim=1))[:, 0]
return anchor_x, vector_x
5 changes: 2 additions & 3 deletions src/netspresso_trainer/postprocessors/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ def yolo_head_decode(pred, original_shape, score_thresh=0.7):
pred = pred['pred']
if isinstance(pred, dict):
pred = pred['outputs']
pred[0][0].type()
h, w = original_shape[1], original_shape[2]
device = pred[0][0].device
stage_strides= [original_shape[-1] // bbox_reg.shape[-1] for bbox_reg, _, _ in pred]
Expand All @@ -221,11 +220,11 @@ def yolo_head_decode(pred, original_shape, score_thresh=0.7):
for layer_output in pred:
bbox_reg, _, class_logits = layer_output
b, c, h, w = bbox_reg.shape
reg = bbox_reg.view(b, c, -1).permute(0, 2, 1)
reg = bbox_reg.permute(0, 2, 3, 1).view(b, h*w, c)
pred_bbox_reg.append(reg)

b, c, h, w = class_logits.shape
logits = class_logits.view(b, c, -1).permute(0, 2, 1)
logits = class_logits.permute(0, 2, 3, 1).view(b, h*w, c)
pred_class_logits.append(logits)

pred_bbox_reg = torch.concat(pred_bbox_reg, dim=1)
Expand Down
Loading