This class allows loading a Custom Dataset in Libtorch.
More...
#include <dataset.hpp>
|
| CustomDataset (std::vector< std::string > list_images, std::vector< int > list_labels, int resize=224) |
|
torch::data::Example | get (size_t index) override |
|
void | show_batch (int grid_size=3) |
| Visualize batch of data (by default 3x3) More...
|
|
void | show_sample (int index) |
|
torch::optional< size_t > | size () const override |
|
Example Usage:
std::pair<std::vector<std::string>, std::vector<int>> pair_images_labels =
load_data_from_folder(folders_name);
std::vector<std::string> list_images = pair_images_labels.first;
std::vector<int> list_labels = pair_images_labels.second;
auto custom_dataset =
CustomDataset(list_images, list_labels, 64);
◆ CustomDataset()
CustomDataset::CustomDataset |
( |
std::vector< std::string > |
list_images, |
|
|
std::vector< int > |
list_labels, |
|
|
int |
resize = 224 |
|
) |
| |
|
inline |
◆ get()
torch::data::Example CustomDataset::get |
( |
size_t |
index | ) |
|
|
inlineoverride |
This should return {torch::Tensor, torch::Tensor}
Arguments:
- index (type: size_t)
◆ show_batch()
void CustomDataset::show_batch |
( |
int |
grid_size = 3 | ) |
|
|
inline |
Arguments:
- grid_size (type: int, default = 3) Saves image in the build/ folder (name: out.jpg)
◆ show_sample()
void CustomDataset::show_sample |
( |
int |
index | ) |
|
|
inline |
Visualizes sample at the given index
◆ size()
torch::optional<size_t> CustomDataset::size |
( |
| ) |
const |
|
inlineoverride |
This function returns size of the dataset
The documentation for this class was generated from the following file:
CustomDataset(std::vector< std::string > list_images, std::vector< int > list_labels, int resize=224)
Definition: dataset.hpp:66
std::pair< std::vector< std::string >, std::vector< int > > load_data_from_folder(std::vector< std::string > folders_name)
Function to load data from given folder(s) name(s) (folders_name) Returns pair of vectors of string (...
Definition: dataset.cpp:69