-
Notifications
You must be signed in to change notification settings - Fork 2
/
SpatiallySparseDatasetImageNet2012.cpp
52 lines (49 loc) · 1.73 KB
/
SpatiallySparseDatasetImageNet2012.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "SpatiallySparseDatasetImageNet2012.h"
#include "SpatiallySparseDatasetOpenCV.h"
#include <iostream>
#include <fstream>
#include <string>
SpatiallySparseDataset ImageNet2012TrainSet() {
auto dataset = OpenCVLabeledDataSet("Data/imagenet2012/classList",
"Data/imagenet2012/ILSVRC2012_img_train",
"*.JPEG", TRAINBATCH, 128, false, 1);
dataset.name = "ImageNet2012 train set";
return dataset;
}
SpatiallySparseDataset ImageNet2012ValidationSet() {
SpatiallySparseDataset dataset;
dataset.name = "ImageNet2012 validation set";
dataset.type = TESTBATCH;
dataset.nFeatures = 3;
dataset.nClasses = 1000;
std::string imageFile;
int cl;
std::ifstream file("Data/imagenet2012/validationData.txt");
int nWidth, nHeight, nBBoxx, nBBoxX, nBBoxy, nBBoxY;
while (file >> cl >> imageFile >> nWidth >> nHeight >> nBBoxx >> nBBoxX >>
nBBoxy >> nBBoxY) {
cl--;
OpenCVPicture *pic = new OpenCVPicture(
std::string("Data/imagenet2012/") + imageFile, 128, cl);
dataset.pictures.push_back(pic);
}
return dataset;
}
SpatiallySparseDataset ImageNet2012TestSet() {
SpatiallySparseDataset dataset;
dataset.name = "ImageNet2012 train set";
dataset.type = UNLABELEDBATCH;
dataset.nFeatures = 3;
dataset.nClasses = 1000;
std::string imageFile;
int cl;
std::ifstream file("Data/imagenet2012/testData.txt");
int nWidth, nHeight, nBBoxx, nBBoxX, nBBoxy, nBBoxY;
while (file >> cl >> imageFile >> nWidth >> nHeight >> nBBoxx >> nBBoxX >>
nBBoxy >> nBBoxY) {
OpenCVPicture *pic = new OpenCVPicture(
std::string("Data/imagenet2012/") + imageFile, 128, -1);
dataset.pictures.push_back(pic);
}
return dataset;
}