Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Initial hacky fix for imagerecordio test flakyness
Browse files Browse the repository at this point in the history
  • Loading branch information
perdasilva committed Nov 5, 2018
1 parent 2c59504 commit 98a9ee7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/io/image_aug_default.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ class DefaultImageAugmenter : public ImageAugmenter {
}
cv::Mat Process(const cv::Mat &src, std::vector<float> *label,
common::RANDOM_ENGINE *prnd) override {
if (!seed_init_state && param_.seed_aug.has_value()) {
/*if (!seed_init_state && param_.seed_aug.has_value()) {
prnd->seed(param_.seed_aug.value());
seed_init_state = true;
}
seed_init_state = false;
}*/
using mshadow::index_t;
bool is_cropped = false;

Expand Down
4 changes: 4 additions & 0 deletions src/io/image_iter_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ struct ImageRecParserParam : public dmlc::Parameter<ImageRecParserParam> {
size_t shuffle_chunk_size;
/*! \brief the seed for chunk shuffling*/
int shuffle_chunk_seed;
/*! \brief random seed for augmentations */
dmlc::optional<int> seed_aug;

// declare parameters
DMLC_DECLARE_PARAMETER(ImageRecParserParam) {
Expand Down Expand Up @@ -165,6 +167,8 @@ struct ImageRecParserParam : public dmlc::Parameter<ImageRecParserParam> {
.describe("The data shuffle buffer size in MB. Only valid if shuffle is true.");
DMLC_DECLARE_FIELD(shuffle_chunk_seed).set_default(0)
.describe("The random seed for shuffling");
DMLC_DECLARE_FIELD(seed_aug).set_default(dmlc::optional<int>())
.describe("Random seed for augmentations.");
}
};

Expand Down
11 changes: 11 additions & 0 deletions src/io/iter_image_recordio_2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,17 @@ inline size_t ImageRecordIOParser2<DType>::ParseChunk(DType* data_dptr, real_t*
cv::Mat res;
rec.Load(blob.dptr, blob.size);
cv::Mat buf(1, rec.content_size, CV_8U, rec.content);

if (idx % 1000 == 0) {
if (param_.seed_aug.has_value()) {
LOG(INFO) << "aug seed: " << param_.seed_aug.value();
}
LOG(INFO) << "tid: " << tid << " idx: " << idx << " index: " << rec.image_index();
}
if (param_.seed_aug.has_value()) {
prnds_[tid]->seed(idx + param_.seed_aug.value());
}

switch (param_.data_shape[0]) {
case 1:
#if MXNET_USE_LIBJPEG_TURBO
Expand Down

0 comments on commit 98a9ee7

Please sign in to comment.