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
9f6cddfd
Unverified
Commit
9f6cddfd
authored
5 years ago
by
Jerry Jiarui XU
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
covert w/o change files (#2184)
parent
e27046d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/convert_datasets/cityscapes.py
+3
-21
3 additions, 21 deletions
tools/convert_datasets/cityscapes.py
with
3 additions
and
21 deletions
tools/convert_datasets/cityscapes.py
+
3
−
21
View file @
9f6cddfd
import
argparse
import
glob
import
os.path
as
osp
from
shutil
import
copyfile
,
move
import
cityscapesscripts.helpers.labels
as
CSLabels
import
mmcv
...
...
@@ -70,13 +69,14 @@ def load_img_info(files):
area
=
area
.
tolist
(),
segmentation
=
mask_rle
)
anno_info
.
append
(
anno
)
video_name
=
osp
.
basename
(
osp
.
dirname
(
img_file
))
img_info
=
dict
(
# remove img_prefix for filename
file_name
=
osp
.
basename
(
img_file
),
file_name
=
osp
.
join
(
video_name
,
osp
.
basename
(
img_file
)
)
,
height
=
inst_img
.
shape
[
0
],
width
=
inst_img
.
shape
[
1
],
anno_info
=
anno_info
,
segm_file
=
osp
.
basename
(
segm_file
))
segm_file
=
osp
.
join
(
video_name
,
osp
.
basename
(
segm_file
))
)
return
img_info
...
...
@@ -110,16 +110,6 @@ def cvt_annotations(image_infos, out_json_name):
return
out_json
def
organize_files
(
files
,
target_dir
,
copy
=
True
):
for
img_file
,
_
,
segm_file
in
files
:
if
copy
:
copyfile
(
img_file
,
osp
.
join
(
target_dir
,
osp
.
basename
(
img_file
)))
copyfile
(
segm_file
,
osp
.
join
(
target_dir
,
osp
.
basename
(
segm_file
)))
else
:
move
(
img_file
,
osp
.
join
(
target_dir
,
osp
.
basename
(
img_file
)))
move
(
segm_file
,
osp
.
join
(
target_dir
,
osp
.
basename
(
segm_file
)))
def
parse_args
():
parser
=
argparse
.
ArgumentParser
(
description
=
'
Convert Cityscapes annotations to COCO format
'
)
...
...
@@ -129,10 +119,6 @@ def parse_args():
parser
.
add_argument
(
'
-o
'
,
'
--out_dir
'
,
help
=
'
output path
'
)
parser
.
add_argument
(
'
--nproc
'
,
default
=
1
,
type
=
int
,
help
=
'
number of process
'
)
parser
.
add_argument
(
'
--clean
'
,
action
=
'
store_true
'
,
help
=
'
whether delete img_dir and gt_dir
'
)
args
=
parser
.
parse_args
()
return
args
...
...
@@ -159,10 +145,6 @@ def main():
osp
.
join
(
img_dir
,
split
),
osp
.
join
(
gt_dir
,
split
))
image_infos
=
collect_annotations
(
files
,
nproc
=
args
.
nproc
)
cvt_annotations
(
image_infos
,
osp
.
join
(
out_dir
,
json_name
))
organize_files
(
files
,
target_dir
=
osp
.
join
(
img_dir
,
split
),
copy
=
not
args
.
clean
)
if
__name__
==
'
__main__
'
:
...
...
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