Applying self transform to image of a dictionary

username: shubz_308
cooked: <p>Hi<br>
i have a dictionary defined in the dataloader<br>
def <strong>getitem</strong>(self, idx):</p>
<pre><code>    image_name = os.path.join(self.__image_path, self.__image_names[idx])
    image = io.imread(image_name)
    joints = self.__mat_data[:-1, :, idx]
    sample = {'image': image, 'joints': joints}
    if self.transform:
        sample = self.transform(sample)
        img = sample['image']
        label = sample['joints']
        
      
    return sample
</code></pre>
<p>i want to apply vertical flip and rotation to the image of this.<br>
How do i write down the self transform<br>
is it self.transform(img)=transforms.compose(transforms.randomverticalflip)<br>
or is there  a way to do this outside of dataloader?</p>

username: my3bikaht
cooked: <p>You can use OpenCV library for transformations like these (cv2.flip, cv2.rotate)</p>

username: mMagmer
cooked: <p>You can use <strong>Albumentations</strong> library. It’s very straight forward to use and supports image with different type of targets.</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://albumentations.ai/docs/getting_started/mask_augmentation/">
  <header class="source">
      <img src="https://albumentations.ai/docs/getting_started/mask_augmentation/../../images/logo.png" class="site-icon" width="190" height="182">

      <a href="https://albumentations.ai/docs/getting_started/mask_augmentation/" target="_blank" rel="noopener nofollow ugc">albumentations.ai</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/309;"><img src="https://albumentations.ai/docs/images/albumentations_card.png" class="thumbnail" width="690" height="309"></div>

<h3><a href="https://albumentations.ai/docs/getting_started/mask_augmentation/" target="_blank" rel="noopener nofollow ugc">Albumentations Documentation - Mask augmentation for segmentation</a></h3>

  <p>Albumentations: fast and flexible image augmentations</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>

<aside class="onebox allowlistedgeneric" data-onebox-src="https://albumentations.ai/docs/getting_started/keypoints_augmentation/">
  <header class="source">
      <img src="https://albumentations.ai/docs/getting_started/keypoints_augmentation/../../images/logo.png" class="site-icon" width="190" height="182">

      <a href="https://albumentations.ai/docs/getting_started/keypoints_augmentation/" target="_blank" rel="noopener nofollow ugc">albumentations.ai</a>
  </header>

  <article class="onebox-body">
    <div class="aspect-image" style="--aspect-ratio:690/309;"><img src="https://albumentations.ai/docs/images/albumentations_card.png" class="thumbnail" width="690" height="309"></div>

<h3><a href="https://albumentations.ai/docs/getting_started/keypoints_augmentation/" target="_blank" rel="noopener nofollow ugc">Albumentations Documentation - Keypoints augmentation</a></h3>

  <p>Albumentations: fast and flexible image augmentations</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>