Thank you for your reply, Martin. The code below is the one for my CustomDataset class.
What happens in the read_data() method?

It reads the text file wich is structured as follows: [Path of one particular image];[label]
After reading the line to the seperator, it stores the image name in the first place of the tuple and then the label.
This is repeated until the file has no further entries

Alle the paths are absolut, both image paths and the path to the label.csv file
class CustomDataset : public torch::data::Dataset<CustomDataset> {

private:

	std::vector<tuple<string,int>> data;// finale Daten, nicht Typ string

public:
	CustomDataset(string img_names_src) {

		 read_data(img_names_src);
	}

	//Method to read the image paths and labels int the vector data
	void read_data(string img_names_src) {

		//Stream to text file
		ifstream name_stream;
		name_stream.open(img_names_src);
		if (!name_stream.good()) {
			std::cout << "Could not open file " << img_names_src << endl;
		}

		//load file names and labels to ram
		int* temp_idx = 0;
		while (name_stream.good()) {
			string img_name;
			string label;
			int int_label;
			getline(name_stream, img_name, ';');
			getline(name_stream, label, '\n');
			int_label = std::stoi(label);
			data.push_back(make_tuple(img_name, int_label));
			temp_idx++;
		}

	std:cout << data.size() << endl;
	}

torch::data::Example<> get(size_t index) override {

		
		//store image in Mat object
		Mat in_img = imread(std::get<0>(data[index]));
		Mat img;
		
		
		//OpenCV data manipulation
		cvtColor(in_img, img, CV_BGR2GRAY);
		
                //normalize to 0.0 and 1.0
		img = img / 255.0; 
		
		Size size(128, 128);
		resize(img, img, size);// set size to 128x128

                //load OpenCV image data to torch::tensor format
		torch::Tensor tensor_image = torch::from_blob(img.data, { img.rows, img.cols,1}, at::kFloat);
                
                //permute dimensions of tensor to Libtorch format
		tensor_image = tensor_image.permute({ 2, 0, 1 });
                
                //load label into torch::Tensor format
		torch::Tensor label_tensor = torch::full({ 1 }, std::get<1>(data[index]));
		
                //return image and corresponding label as tensor data
		return { tensor_image, label_tensor };

	}

	torch::optional<size_t> size() const override {

		return data.size();
	};

};