-
Notifications
You must be signed in to change notification settings - Fork 613
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
COCOReader: Support for uncompressed RLE masks #2478
COCOReader: Support for uncompressed RLE masks #2478
Conversation
49aa2fa
to
538c4db
Compare
ASSERT_EQ(pixelwise_masks_shape[i][0], s.height); | ||
EXPECT_EQ(0, std::memcmp(mask.data, labels.data(), s.width * s.height * sizeof(uchar))); | ||
Pipeline pipe2(expected_size, 1, 0, kSeed); | ||
pipe2.AddOperator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second pipeline to test loading from preprocessed binary files
!build |
@@ -59,6 +63,39 @@ inline bool HasSavePreprocessedAnnotationsDir(const OpSpec &spec) { | |||
(spec.HasArgument("dump_meta_files_path") && spec.GetArgument<bool>("dump_meta_files_path")); | |||
} | |||
|
|||
struct RLEMask { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder... if you expose all the fields for modification, then this looks more like a C++ variant of the RLE structure - then maybe this should be handled by inheritance?
struct RLEMask { | |
struct RLEMask : RLE { |
Otherwise, you can treat RLE as a resource and use struct RLEMask : UniqueResource<RLE>
:
struct RLEMask : UniqueResource<RLE> {
RLEMask(const char* str, int h, int w) {
rleFrString(&handle_, const_cast<char*>(str), h, w);
}
RLEMask(span<const unsigned int> counts, int h, int w) {
rleInit(&handle_, h, w, counts.size(), const_cast<unsigned int*>(counts.data()));
}
RLE* operator->() { return &rle_; } // do you really need this one?
const RLE* operator->() const { return &rle_; }
void DestroyHandle(RLE rle) {
if (rle.cnts)
rleFree(&rle);
}
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
CI MESSAGE: [1814491]: BUILD STARTED |
CI MESSAGE: [1814491]: BUILD FAILED |
!build |
CI MESSAGE: [1814766]: BUILD STARTED |
CI MESSAGE: [1814766]: BUILD FAILED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!build
!build |
return; | ||
|
||
unsigned size; | ||
file.read(reinterpret_cast<char*>(&size), sizeof(unsigned)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are already touching this can you:
- check
size
is smaller than the file size and >=0 m * sizeof(uint)
is smaller than the file size and >= 0h
andw
are sane as well?
Do the same for other LoadFromFile
variants?
CI MESSAGE: [1815816]: BUILD STARTED |
CI MESSAGE: [1815816]: BUILD FAILED |
dad74cb
to
853328a
Compare
!build |
CI MESSAGE: [1824283]: BUILD STARTED |
CI MESSAGE: [1824283]: BUILD FAILED |
!build |
CI MESSAGE: [1824670]: BUILD STARTED |
CI MESSAGE: [1824670]: BUILD FAILED |
84511f1
to
2b1c1e5
Compare
!build |
CI MESSAGE: [1824967]: BUILD STARTED |
CI MESSAGE: [1824967]: BUILD FAILED |
2b1c1e5
to
72b34d1
Compare
Signed-off-by: Joaquin Anton <janton@nvidia.com>
Signed-off-by: Joaquin Anton <janton@nvidia.com>
CI MESSAGE: [1828400]: BUILD STARTED |
CI MESSAGE: [1828400]: BUILD PASSED |
.AddArg("dump_meta_files_path", "/tmp/") | ||
, | ||
.AddArg("save_preprocessed_annotations", true) | ||
.AddArg("save_preprocessed_annotations_dir", "/tmp/"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should use mkdtmp instead of hardcode to just /tmp/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: Joaquin Anton <janton@nvidia.com>
ddfe592
to
ebdf7d7
Compare
DALI_EXTRA_VERSION
Outdated
@@ -1 +1 @@ | |||
fdd536addddc0f1a5bd52a15db708f95492c813e | |||
rle_uncompressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to a commit tag before merging!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course
rleFrString(&handle_, const_cast<char*>(str), h, w); | ||
} | ||
|
||
static constexpr RLE null_handle() { return {0, 0, 0, nullptr}; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this? Won't the default just work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember it didn't work (ptr was not nullptr, if I remember correctly). I could double-check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work, so I am removing it
sample_rles_idx.push_back(objects_in_sample); | ||
sample_rles.push_back(std::move(annotation.rle_.rle_)); | ||
masks_rles_idx_.push_back(objects_in_sample); | ||
masks_rles_.emplace_back(std::move(annotation.rle_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick:
masks_rles_.emplace_back(std::move(annotation.rle_)); | |
masks_rles_.push_back(std::move(annotation.rle_)); |
std::vector<RLEMask> masks_rles_; | ||
std::vector<int> masks_rles_idx_; | ||
std::vector<int64_t> masks_offset_; // per sample offset | ||
std::vector<int64_t> masks_count_; // per sample size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick
std::vector<int64_t> masks_count_; // per sample size | |
std::vector<int64_t> mask_counts_ // number of masks per sample |
std::vector<std::vector<int>> masks_rles_idx_; | ||
std::vector<RLEMask> masks_rles_; | ||
std::vector<int> masks_rles_idx_; | ||
std::vector<int64_t> masks_offset_; // per sample offset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::vector<int64_t> masks_offset_; // per sample offset | |
std::vector<int64_t> mask_offsets_; // per-sample offsets of masks |
int64_t polygons_sample_offset = polygon_data_.size(); | ||
int64_t polygons_sample_count = 0; | ||
int64_t vertices_sample_offset = vertices_data_.size(); | ||
int64_t vertices_sample_count = 0; | ||
int64_t masks_offset = masks_rles_.size(); | ||
int64_t masks_count = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int64_t masks_count = 0; | |
int64_t mask_count = 0; |
@@ -392,14 +504,14 @@ void CocoLoader::ParseJsonAnnotations() { | |||
|
|||
for (auto &image_info : image_infos) { | |||
int objects_in_sample = 0; | |||
std::vector<int> sample_rles_idx; | |||
std::vector<std::string> sample_rles; | |||
int64_t polygons_sample_offset = polygon_data_.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reads as "offset of a sample in polygons". I think it means the opposite and then it should be sample_polygon(s)_offset, sample_polygon_count, sample_vertex_offset / vertices_offset, sample_vertex_count etc.
Offsets can be preceded by a plural form because it's the offset of a block/range of polygons - "polygons" is the object.
Count should be preceded by a singular form, because we're going into the aforementioned region and counting individual object. If you're terribly attached to a plural form, then it could be polygons_size / vertices_size.
qa/setup_dali_extra.sh
Outdated
@@ -2,7 +2,7 @@ | |||
|
|||
# Fetch test data | |||
export DALI_EXTRA_PATH=${DALI_EXTRA_PATH:-/opt/dali_extra} | |||
export DALI_EXTRA_URL=${DALI_EXTRA_URL:-"https://github.com/NVIDIA/DALI_extra.git"} | |||
export DALI_EXTRA_URL="https://github.com/jantonguirao/DALI_extra.git" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix before merging.
qa/setup_dali_extra.sh
Outdated
@@ -13,6 +13,5 @@ if [ ! -d "$DALI_EXTRA_PATH" ] ; then | |||
fi | |||
|
|||
pushd "$DALI_EXTRA_PATH" | |||
git fetch origin ${DALI_EXTRA_VERSION} | |||
git checkout ${DALI_EXTRA_VERSION} | |||
git checkout rle_uncompressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix before merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With fixes to DALI_extra that Michał pointed out it looks ok
80e085e
to
e829cdf
Compare
!build |
CI MESSAGE: [1839138]: BUILD STARTED |
CI MESSAGE: [1839138]: BUILD FAILED |
Signed-off-by: Joaquin Anton <janton@nvidia.com>
e829cdf
to
57171bd
Compare
!build |
CI MESSAGE: [1839192]: BUILD STARTED |
CI MESSAGE: [1839192]: BUILD PASSED |
Signed-off-by: Joaquin Anton janton@nvidia.com
Why we need this PR?
Pick one, remove the rest
What happened in this PR?
Fill relevant points, put NA otherwise. Replace anything inside []
Added support for preprocessed annotation files describing RLE masks
Using cocoapi RLE struct to store the RLE masks.
COCOReader
All
C++ Tests enhanced, new data added to DALI_extra
N/A
JIRA TASK: [DALI-1732]