14 #ifndef ECVL_DATASET_PARSER_H_ 15 #define ECVL_DATASET_PARSER_H_ 28 #include "yaml-cpp/yaml.h" 31 #define UNSIGNED_ENUM_CLASS(name, ...) enum class name : unsigned { __VA_ARGS__ };\ 32 inline constexpr unsigned operator+ (name const val) { return static_cast<unsigned>(val); } 103 Split(
const std::string& split_name,
const std::vector<int>& samples_indices,
const bool drop_last =
false,
const bool no_label =
false)
133 std::map<std::string, int> features_map_;
134 void DecodeImages(
const YAML::Node& node,
const filesystem::path& root_path,
bool verify);
135 void FindLabel(
Sample& sample,
const YAML::Node& n);
140 std::string
name_ =
"DeepHealth dataset";
155 Dataset(
const filesystem::path& filename,
bool verify =
false);
180 void Dump(
const filesystem::path& file_path);
188 std::vector<std::vector<filesystem::path>>
GetLocations()
const;
195 #endif // ECVL_DATASET_PARSER_H_ std::vector< Split > split_
Splits of the Dataset. See Split.
const int GetSplitIndex(ecvl::any split)
Split(const std::string &split_name, const std::vector< int > &samples_indices, const bool drop_last=false, const bool no_label=false)
void Dump(const filesystem::path &file_path)
Dump the Dataset into a YAML file following the DeepHealth Dataset Format.
optional< std::vector< int > > label_
Vector of sample labels.
std::vector< ecvl::Split >::iterator GetSplitIt(ecvl::any split)
int vsize(const std::vector< T > &v)
std::vector< std::string > classes_
Vector with all the classes available in the Dataset.
std::string description_
Description of the Dataset.
ColorType
Enum class representing the ECVL supported color spaces.
std::vector< std::string > features_
Vector with all the features available in the Dataset.
std::vector< int > size_
Original x and y dimensions of the sample.
void SetLastBatch(int batch_size)
#define UNSIGNED_ENUM_CLASS(name,...)
std::vector< int > samples_indices_
Vector containing samples indices of the split.
optional< std::map< int, std::string > > values_
Map (map<feature-index,feature-value>) which stores the features of a sample.
std::vector< int > & GetSplit(const ecvl::any &split=-1)
Returns the image indexes of the requested split.
std::vector< std::vector< filesystem::path > > GetLocations() const
Retrieve the list of all samples locations in the dataset file.
optional< filesystem::path > label_path_
Absolute path of sample ground truth.
int current_split_
Current split from which images are loaded.
void SetSplit(const ecvl::any &split)
Set the current split.
std::vector< filesystem::path > location_
Absolute path of the sample.
Task task_
Task of the dataset.
ecvl::Image LoadImage(ecvl::ColorType ctype=ecvl::ColorType::RGB, const bool &is_gt=false)
Return an Image of the dataset.
void SetNumBatches(int batch_size)
Sample image in a dataset.
Split of a dataset. This class provides the name of the split and the indices of the samples that bel...
std::experimental::optional< T > optional
optional< SplitType > split_type_
If the split is training, validation or test the corresponding SpitType is provided.
std::string name_
Name of the Dataset.
std::string split_name_
Name of the split.
std::experimental::any any
Task
Enum class representing allowed tasks for the ECVL Dataset.
int last_batch_
Dimension of the last batch of this split.
static const std::regex url_regex_
SplitType
Enum class representing the Dataset supported splits.
int num_batches_
Number of batches of this split.
std::vector< Sample > samples_
Vector containing all the Dataset samples. See Sample.
bool no_label_
Whether the split has samples with labels or not.
bool drop_last_
Whether to drop elements that don't fit batch size or not.