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

Fix floordiv warning. #8717

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dc49646
Fix floordiv warning.
JiayuXu0 Sep 3, 2022
9aec944
Merge branch 'open-mmlab:dev-3.x' into dev-3.x
JiayuXu0 Sep 6, 2022
23faa97
[Fix] Fix a grammatical error in docstr (#8639)
gaotongxiao Aug 26, 2022
aee70c5
[Refactor]: rename config without changing the content (#8603)
Aug 25, 2022
64e1531
rename extra config
Aug 25, 2022
a68c1c9
[Refactor]: change config content (#8635)
Aug 26, 2022
d6272e4
[Update]: update benchmark list (#8643)
hhaAndroid Aug 26, 2022
5a9068b
[Feature] Add BaseDetDataset (#8596)
BIGWangYuDong Aug 26, 2022
3a9f8aa
[Fix]: rename remaining configs (#8644)
Aug 26, 2022
3841490
[Fix]: Refactor multi branch according to new data flow (#8634)
Czm369 Aug 26, 2022
b8f5a90
[Fix]: Fix unit tests of MeanTeacherHook and TeacherStudentValLoop (#…
Czm369 Aug 26, 2022
564e423
[Fix] Fix docs: new_data_model, exist_data_new_model, customize_model…
chhluo Aug 29, 2022
b23df47
[Fix] Fix docs:1_exist_data_model.md,how_to.md,useful_tools.md,change…
Aug 30, 2022
a939309
[DOCS] Use FCOS as a rpn head in Faster R-CNN (#8652)
chhluo Aug 30, 2022
465da72
[Doc]SSOD tutorial (#8624)
Czm369 Aug 30, 2022
653b255
[Refactor] Refactor doc structures. (#8660)
RangiLyu Aug 30, 2022
e144a5e
[Fix] Fix the doc (#8682)
Czm369 Aug 31, 2022
8d19057
[Docs] Refine customize_models/customize_runtime/customize_models/how…
hhaAndroid Aug 31, 2022
6cd8b0f
[Doc]: update 3.x readme (#8681)
RangiLyu Aug 31, 2022
bf7419e
[Docs] update link (#8684)
BIGWangYuDong Aug 31, 2022
1e86f4f
[Docs] fix init_cfg.md (#8676)
zytx121 Aug 31, 2022
21c9033
[Docs] Update test_result_submission, useful_hooks, finetuning_models…
chhluo Aug 31, 2022
fdaca1c
[Docs] Update English and Chinese get_started and FAQ (#8683)
BIGWangYuDong Aug 31, 2022
1b0929a
[Doc]: Add changelog for 3.x (#8685)
ZwwWayne Aug 31, 2022
7ce8b49
Update (#8689)
jbwang1997 Sep 1, 2022
7999976
add deploy yml (#8691)
hhaAndroid Sep 1, 2022
2da8744
[Doc]: Update changelog and clean docs (#8692)
ZwwWayne Sep 1, 2022
f708af3
[Fix]: remove test requirements from all (#8693)
ZwwWayne Sep 1, 2022
33ed88c
Fix typos in changelog (#8694)
ZwwWayne Sep 1, 2022
9ed9b51
[Fix]: fix test requirements and typos (#8695)
ZwwWayne Sep 1, 2022
e13d701
[Fix] Fix UT to be compatible with pytorch 1.6 (#8707)
jbwang1997 Sep 5, 2022
2842493
Merge branch 'dev-3.x' of github.com:JiayuXu0/mmdetection into dev-3.x
JiayuXu0 Sep 6, 2022
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
35 changes: 25 additions & 10 deletions mmdet/models/dense_heads/solo_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from mmdet.registry import MODELS
from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptConfigType
from mmdet.utils.misc import floordiv
from ..layers import mask_matrix_nms
from ..utils import center_of_mass, generate_coordinate, multi_apply
from .base_mask_head import BaseMaskHead
Expand Down Expand Up @@ -396,27 +397,41 @@ def _get_targets_single(self,
center_h, center_w = center_of_mass(gt_mask)

coord_w = int(
(center_w / upsampled_size[1]) // (1. / num_grid))
floordiv((center_w / upsampled_size[1]), (1. / num_grid),
rounding_mode='trunc'))
coord_h = int(
(center_h / upsampled_size[0]) // (1. / num_grid))
floordiv((center_h / upsampled_size[0]), (1. / num_grid),
rounding_mode='trunc'))

# left, top, right, down
top_box = max(
0,
int(((center_h - pos_h_range) / upsampled_size[0]) //
(1. / num_grid)))
int(
floordiv(
(center_h - pos_h_range) / upsampled_size[0],
(1. / num_grid),
rounding_mode='trunc')))
down_box = min(
num_grid - 1,
int(((center_h + pos_h_range) / upsampled_size[0]) //
(1. / num_grid)))
int(
floordiv(
(center_h + pos_h_range) / upsampled_size[0],
(1. / num_grid),
rounding_mode='trunc')))
left_box = max(
0,
int(((center_w - pos_w_range) / upsampled_size[1]) //
(1. / num_grid)))
int(
floordiv(
(center_w - pos_w_range) / upsampled_size[1],
(1. / num_grid),
rounding_mode='trunc')))
right_box = min(
num_grid - 1,
int(((center_w + pos_w_range) / upsampled_size[1]) //
(1. / num_grid)))
int(
floordiv(
(center_w + pos_w_range) / upsampled_size[1],
(1. / num_grid),
rounding_mode='trunc')))

top = max(top_box, coord_h - 1)
down = min(down_box, coord_h + 1)
Expand Down
35 changes: 25 additions & 10 deletions mmdet/models/dense_heads/solov2_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from torch import Tensor

from mmdet.utils import ConfigType, InstanceList, MultiConfig, OptConfigType
from mmdet.utils.misc import floordiv
from ..builder import HEADS
from ..layers import mask_matrix_nms
from ..utils import center_of_mass, generate_coordinate, multi_apply
Expand Down Expand Up @@ -417,27 +418,41 @@ def _get_targets_single(self,
center_h, center_w = center_of_mass(gt_mask)

coord_w = int(
(center_w / upsampled_size[1]) // (1. / num_grid))
floordiv((center_w / upsampled_size[1]), (1. / num_grid),
rounding_mode='trunc'))
coord_h = int(
(center_h / upsampled_size[0]) // (1. / num_grid))
floordiv((center_h / upsampled_size[0]), (1. / num_grid),
rounding_mode='trunc'))

# left, top, right, down
top_box = max(
0,
int(((center_h - pos_h_range) / upsampled_size[0]) //
(1. / num_grid)))
int(
floordiv(
(center_h - pos_h_range) / upsampled_size[0],
(1. / num_grid),
rounding_mode='trunc')))
down_box = min(
num_grid - 1,
int(((center_h + pos_h_range) / upsampled_size[0]) //
(1. / num_grid)))
int(
floordiv(
(center_h + pos_h_range) / upsampled_size[0],
(1. / num_grid),
rounding_mode='trunc')))
left_box = max(
0,
int(((center_w - pos_w_range) / upsampled_size[1]) //
(1. / num_grid)))
int(
floordiv(
(center_w - pos_w_range) / upsampled_size[1],
(1. / num_grid),
rounding_mode='trunc')))
right_box = min(
num_grid - 1,
int(((center_w + pos_w_range) / upsampled_size[1]) //
(1. / num_grid)))
int(
floordiv(
(center_w + pos_w_range) / upsampled_size[1],
(1. / num_grid),
rounding_mode='trunc')))

top = max(top_box, coord_h - 1)
down = min(down_box, coord_h + 1)
Expand Down
14 changes: 14 additions & 0 deletions mmdet/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import os.path as osp
import warnings

import torch
from mmengine.config import Config, ConfigDict
from mmengine.logging import print_log
from mmengine.utils import digit_version


def find_latest_checkpoint(path, suffix='pth'):
Expand Down Expand Up @@ -74,3 +76,15 @@ def update(cfg, src_str, dst_str):

update(cfg.data, cfg.data_root, dst_root)
cfg.data_root = dst_root


_torch_version_div_indexing = (
'parrots' not in torch.__version__
and digit_version(torch.__version__) >= digit_version('1.8'))


def floordiv(dividend, divisor, rounding_mode='trunc'):
if _torch_version_div_indexing:
return torch.div(dividend, divisor, rounding_mode=rounding_mode)
else:
return dividend // divisor