Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
de125c4e
You need to sign in or sign up before continuing.
Commit
de125c4e
authored
May 23, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[MaskRCNN] fix small issues in COCO loader
parent
9b318943
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
examples/FasterRCNN/dataset/coco.py
examples/FasterRCNN/dataset/coco.py
+8
-1
No files found.
examples/FasterRCNN/dataset/coco.py
View file @
de125c4e
...
@@ -52,6 +52,7 @@ class COCODetection(DatasetSplit):
...
@@ -52,6 +52,7 @@ class COCODetection(DatasetSplit):
from
pycocotools.coco
import
COCO
from
pycocotools.coco
import
COCO
self
.
coco
=
COCO
(
annotation_file
)
self
.
coco
=
COCO
(
annotation_file
)
self
.
annotation_file
=
annotation_file
logger
.
info
(
"Instances loaded from {}."
.
format
(
annotation_file
))
logger
.
info
(
"Instances loaded from {}."
.
format
(
annotation_file
))
# https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
# https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocoEvalDemo.ipynb
...
@@ -126,6 +127,11 @@ class COCODetection(DatasetSplit):
...
@@ -126,6 +127,11 @@ class COCODetection(DatasetSplit):
# ann_ids = self.coco.getAnnIds(imgIds=img['image_id'])
# ann_ids = self.coco.getAnnIds(imgIds=img['image_id'])
# objs = self.coco.loadAnns(ann_ids)
# objs = self.coco.loadAnns(ann_ids)
objs
=
self
.
coco
.
imgToAnns
[
img
[
'image_id'
]]
# equivalent but faster than the above two lines
objs
=
self
.
coco
.
imgToAnns
[
img
[
'image_id'
]]
# equivalent but faster than the above two lines
if
'minival'
not
in
self
.
annotation_file
:
# TODO better to check across the entire json, rather than per-image
ann_ids
=
[
ann
[
"id"
]
for
ann
in
objs
]
assert
len
(
set
(
ann_ids
))
==
len
(
ann_ids
),
\
"Annotation ids in '{}' are not unique!"
.
format
(
self
.
annotation_file
)
# clean-up boxes
# clean-up boxes
valid_objs
=
[]
valid_objs
=
[]
...
@@ -171,7 +177,8 @@ class COCODetection(DatasetSplit):
...
@@ -171,7 +177,8 @@ class COCODetection(DatasetSplit):
# add the keys
# add the keys
img
[
'boxes'
]
=
boxes
# nx4
img
[
'boxes'
]
=
boxes
# nx4
assert
cls
.
min
()
>
0
,
"Category id in COCO format must > 0!"
if
len
(
cls
):
assert
cls
.
min
()
>
0
,
"Category id in COCO format must > 0!"
img
[
'class'
]
=
cls
# n, always >0
img
[
'class'
]
=
cls
# n, always >0
img
[
'is_crowd'
]
=
is_crowd
# n,
img
[
'is_crowd'
]
=
is_crowd
# n,
if
add_mask
:
if
add_mask
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment