Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Swin-Transformer-Object-Detection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wanggh
Swin-Transformer-Object-Detection
Commits
21fef035
Unverified
Commit
21fef035
authored
4 years ago
by
Wenwei Zhang
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix parrots compatibility issues (#4143)
* fix parrots compatibility * add comments
parent
1cbe18b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mmdet/core/export/pytorch2onnx.py
+6
-5
6 additions, 5 deletions
mmdet/core/export/pytorch2onnx.py
mmdet/datasets/samplers/group_sampler.py
+5
-2
5 additions, 2 deletions
mmdet/datasets/samplers/group_sampler.py
with
11 additions
and
7 deletions
mmdet/core/export/pytorch2onnx.py
+
6
−
5
View file @
21fef035
...
...
@@ -5,11 +5,6 @@ import numpy as np
import
torch
from
mmcv.runner
import
load_checkpoint
try
:
from
mmcv.onnx.symbolic
import
register_extra_symbolics
except
ModuleNotFoundError
:
raise
NotImplementedError
(
'
please update mmcv to version>=v1.0.4
'
)
def
generate_inputs_and_wrap_model
(
config_path
,
checkpoint_path
,
input_config
):
"""
Prepare sample input and wrap model for ONNX export.
...
...
@@ -51,6 +46,12 @@ def generate_inputs_and_wrap_model(config_path, checkpoint_path, input_config):
# pytorch has some bug in pytorch1.3, we have to fix it
# by replacing these existing op
opset_version
=
11
# put the import within the function thus it will not cause import error
# when not using this function
try
:
from
mmcv.onnx.symbolic
import
register_extra_symbolics
except
ModuleNotFoundError
:
raise
NotImplementedError
(
'
please update mmcv to version>=v1.0.4
'
)
register_extra_symbolics
(
opset_version
)
return
model
,
tensor_data
...
...
This diff is collapsed.
Click to expand it.
mmdet/datasets/samplers/group_sampler.py
+
5
−
2
View file @
21fef035
...
...
@@ -103,8 +103,11 @@ class DistributedGroupSampler(Sampler):
if
size
>
0
:
indice
=
np
.
where
(
self
.
flag
==
i
)[
0
]
assert
len
(
indice
)
==
size
indice
=
indice
[
list
(
torch
.
randperm
(
int
(
size
),
generator
=
g
))].
tolist
()
# add .numpy() to avoid bug when selecting indice in parrots.
# TODO: check whether torch.randperm() can be replaced by
# numpy.random.permutation().
indice
=
indice
[
list
(
torch
.
randperm
(
int
(
size
),
generator
=
g
).
numpy
())].
tolist
()
extra
=
int
(
math
.
ceil
(
size
*
1.0
/
self
.
samples_per_gpu
/
self
.
num_replicas
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment