Git Product home page Git Product logo

copy-paste-aug's Introduction

copy-paste-aug's People

Contributors

conradry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

copy-paste-aug's Issues

RandomScale of albumentations drops "bboxes" content in coco annotations

Running the example jupyter , the "bboxes" is [] for both img_data and paste_img_data in code
img_data = self.copy_paste(**img_data, **paste_img_data) . The empty bboxe causes the augmentation failed. I'm sure that "bboxes" extracted from annotations. My data is standard coco format. And the program works when drop other aug before CopyPaste.

How do I use this augment data?

I have successfully run your program. Now I want to know how to use the data, to train the model directly, or to save the data and train the model with the original data?

AttributeError: 'CopyPaste' object has no attribute '_to_dict'

/usr/local/lib/python3.6/dist-packages/albumentations/core/composition.py in <listcomp>(.0)
     97             "__class_fullname__": self.get_class_fullname(),
     98             "p": self.p,
---> 99             "transforms": [t._to_dict() for t in self.transforms],  # skipcq: PYL-W0212
    100         }
    101 

AttributeError: 'CopyPaste' object has no attribute '_to_dict'

How to use copy-paste augmentation for YOLOX object detection

Hey @conradry,Thank you for your work!
Could you tell me how can i use the copy-paste augmentation in YOLOX. The dataset for YOLOX should be in COCO format, and I already have my custom dataset, so I tried do some copy-paste-aug on my data, but it didn't work...any idea how can I use it in yoloX?
And if theres is a way to save augmented data (img and annotations.json) to different folder, I'd be glad to know.

How To Visualize Augmented Images in As presented in Fig 2.

@conradry Very interesting work done. Thanks. The 'example.ipynb' does not display augmented images as presented in figure 2 of the original paper. Can you advise on how to reproduce and visualize the augmentation effect as observed in the newly created images as presented in Fig 2 of the paper?

Mosaic can't be used for Instance Segmentation?

The Mosaic transformation can not be used for Instance Segmentation?

I constructed the instance segmentation config according to the format of objecti detection (add ‘gt_masks’), but get an error.

image

The example script is no use for my aerial image

Thank you for your work. But may more situations should be considered. With no changes to your example script , the aug failed for my aerial image. There is no data format problem in the process.

Reproduce results in Paper

Have you been able to reproduce the results achieved in the paper with this unofficial implementation?

Torchvision Dataset Integration

I developed my own dataset class. However, I keep getting a strange error.
This is my code

from copy_paste import copy_paste_class
from torch.utils.data import Dataset
import torchvision.transforms as transforms

@copy_paste_class
class DatasetClass(Dataset):
    def __init__(self, df, transforms = None):
        self.df = df
        self.transforms = transforms
        
    def __len__(self):
        return len(self.df)
    
    def load_example(self,index):
        #locally
#         img_path = self.df['imagePath'][index]
        # on DGX    
        img_path = self.df['imagePath'][index]
        
        img_label = self.df['class'][index]
        img_PIL = Image.open(img_path)
        print('done')
        if img_PIL.mode != "RGB":
            img_PIL = img_PIL.convert('RGB')          
        border = (int(self.df['xmin'][index]),\
                  int(self.df['ymin'][index]),\
                  int(self.df['xmax'][index]),\
                  int(self.df['ymax'][index])) # left, top, right, bottom
        img_PIL = img_PIL.crop(border)
        image = img_PIL
        image = self.transforms(image)
        
        return image, img_label_idx




import albumentations as A
from albumentations.pytorch.transforms import ToTensorV2
from copy_paste import CopyPaste


transforms = A.Compose([
      A.RandomScale(scale_limit=(-0.9, 1), p=1), #LargeScaleJitter from scale of 0.1 to 2
      A.PadIfNeeded(256, 256, border_mode=0), #constant 0 border
      A.HorizontalFlip(p=0.5),
      CopyPaste(blend=True, sigma=1, pct_objects_paste=0.5, p=1)
    ], bbox_params=A.BboxParams(format="coco")
)

Finally, this is the error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/tmp/ipykernel_16726/2411785438.py in <module>
----> 1 dataset[0]

~/Desktop/nas/vision/Orjuwan/LDR/Experiments/LogoDetection/YOLOv5/copy_paste.py in __getitem__(self, idx)
    298             self._split_transforms()
    299 
--> 300         img_data = self.load_example(idx)
    301         if self.copy_paste is not None:
    302             paste_idx = random.randint(0, self.__len__() - 1)

/tmp/ipykernel_16726/579992425.py in load_example(self, index)
     29         img_PIL = img_PIL.crop(border)
     30         image = img_PIL
---> 31         image = self.transforms(image)
     32 
     33         return image, img_label_idx

~/anaconda3/lib/python3.8/site-packages/albumentations/core/composition.py in __call__(self, force_apply, *args, **data)
    191     def __call__(self, *args, force_apply=False, **data):
    192         if args:
--> 193             raise KeyError("You have to pass data to augmentations as named arguments, for example: aug(image=image)")
    194         if self.is_check_args:
    195             self._check_args(**data)

KeyError: 'You have to pass data to augmentations as named arguments, for example: aug(image=image)'

An error occurred while using Copy-Paste!

ValueError: Expected x_max for bbox (0.65, 0.51, 1.12, 0.64, 3) to be in the range [0.0, 1.0], got 1.1234809015877545
Augmentation I use:
aug_list = [A.Resize(800,800),
CopyPaste(blend=True, sigma=1, pct_objects_paste=0.6, p=0.5) #pct_objects_paste is a guess
]
transform = A.Compose(
aug_list, bbox_params=A.BboxParams(format="coco")
)
Can anyone tell me where is the problem?

copy paste to background image

Hi @conradry , first of all thanks for your great work,
I want to use copy paste to copy annotation from original image to a background image without annotations. How can I do it ?

How to use copy-paste augmentation for YOLO5 object detection

Hey @conradry,
I'm curios to know how can i use the copy-paste augmentation in YOLO. Im using albumentations to do some augmentation on my custom dataset and I have added the copy-paste aug as you said in the readme file but im not able to make it work! im getting an error that needs the mask params... which I dont have it! any idea how can I use it in yolov5 detection??

transform = A.Compose([
       A.NoOp(p=0.4),
       A.RandomScale(p=0.2)
       CopyPaste(blend=True, sigma=1, pct_objects_paste=0.5, p=1)
], bbox_params=A.BboxParams(format="pascal_voc"))

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.