Skip to content

Commit

Permalink
no augment if not set
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyetx committed Apr 25, 2016
1 parent 116c116 commit ad7b07b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ You should prepare your own data. You need two kinds of data, face with landmark
....
```

bbox in `face.txt` indicate the face region. You can turn on data augment which will flip the face, but you also need to give symmetric landmarks index for flip operation. If bbox is out of range of the original image, the program will fill the rest region with black.
bbox in `face.txt` indicate the face region. You can turn on data augment which will flip the face, but you also need to give **symmetric landmarks index** for flip operation. If bbox is out of range of the original image, the program will fill the rest region with black.

`background.txt` is much more simpler. Every line indicates where the background image in the file system.

Expand Down
2 changes: 1 addition & 1 deletion config.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}
},
"face": {
"online_augment": true,
"online_augment": false,
"symmetric_landmarks": {
"offset": 1,
"left": [1, 2, 5, 6, 7, 8, 9, 19, 22],
Expand Down
22 changes: 13 additions & 9 deletions src/jda/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,14 +878,14 @@ void NegGenerator::Load(const vector<string>& path) {
}
fclose(file);

const int n = hd_list.size();
hds.resize(2 * n);

int threads_n = omp_get_max_threads();
omp_set_num_threads(3 * threads_n);
cv::waitKey(1000);
SLEEP(1000);
LOG("Load All Hard Negative Samples from text file");

const int n = hd_list.size();
hds.resize(n);

#pragma omp parallel for
for (int i = 0; i < n; i++) {
Mat img = cv::imread(hd_list[i], CV_LOAD_IMAGE_GRAYSCALE);
Expand All @@ -894,21 +894,25 @@ void NegGenerator::Load(const vector<string>& path) {
continue;
}
cv::resize(img, img, Size(c.img_o_size, c.img_o_size));
Mat img_flip;
cv::flip(img, img_flip, 1);
hds[i] = img;
hds[i + n] = img_flip;
}

omp_set_num_threads(threads_n);
SLEEP(1000);
LOG("All hard negative samples Done");

if (false) {
hds.resize(2 * n);
for (int i = 0; i < n; i++) {
if (hds[i].data) cv::flip(hds[i], hds[i + n], 1);
}
}

LOG("Snapshot hard negative");
FILE* data = fopen("../data/dump/hard.data", "wb");
int n2 = 2 * n;
int n2 = hds.size();
fwrite(&n2, sizeof(int), 1, data);
for (int i = 0; i < hds.size(); i++) {
for (int i = 0; i < n2; i++) {
Mat& img = hds[i];
if (!img.data) {
int t4 = 0;
Expand Down

0 comments on commit ad7b07b

Please sign in to comment.