Tiago-Roxo / YinYang-Net

Apache License 2.0
8 stars 1 forks source link

How can I get the image info from custom dataset? #4

Open mohamedabdallah1996 opened 2 years ago

mohamedabdallah1996 commented 2 years ago

I built a custom dataloader so that I can train or test on a custom dataset. but I have a problem, I don't know how to get the image info or especially the orientation of the image with the same format you are using to pass it to the model.

Can you please tell me how can I get this info for a custom dataset? Thank you.

Tiago-Roxo commented 2 years ago

Hello.

Sorry for the late response.

Perhaps the following file will help in your task: https://drive.google.com/file/d/10yi94NKOmfVYy1UaPMo_THIBB-GwqYOz/view?usp=sharing With this file, we are creating a .pkl (line 123) which is our input for dataset reading, reading the PETA dataset from a .mat, provided by the authors of PETA dataset (lines 49 and 87-89). Note line 101 (dataset.partition.train_info.append(list_img_info)). In this line, we are adding image information to the train partition of our dataset. This image information comes from a dictionary and is grouped in a list, transformed into an np.array (lines 29-42). The key point here is that you can pass your own information (either from this file or reading from a dictionary like we did, in line 84) to a list (i.e., list_img_info) and pass this list to your train and/or test partition, as we did.

If you prepare the information this way, you can reuse (or adapt) our dataset/AttrDataset.py, accessing this information as we did in line 42 (self.image_info). Another aspect is that we pass 7 types of data (resolution, brightness, ..., orientation, lines 29-42 of the file in the link provided), but we only access orientation to train and test our model. We can see this access of information in line 93 of models/base_clock_meta.py (img_orientation = img_info[:,6]). If you want to use more information (e.g., resolution), you can access it here (e.g., img_orientation = img_info[:,0]) and adapt the model to consider this complementary information.