Code Monkey home page Code Monkey logo

augly's Introduction

logo


AugLy is a data augmentations library that currently supports four modalities (audio, image, text & video) and over 100 augmentations. Each modality’s augmentations are contained within its own sub-library. These sub-libraries include both function-based and class-based transforms, composition operators, and have the option to provide metadata about the transform applied, including its intensity.

AugLy is a great library to utilize for augmenting your data in model training, or to evaluate the robustness gaps of your model! We designed AugLy to include many specific data augmentations that users perform in real life on internet platforms like Facebook's -- for example making an image into a meme, overlaying text/emojis on images/videos, reposting a screenshot from social media. While AugLy contains more generic data augmentations as well, it will be particularly useful to you if you're working on a problem like copy detection, hate speech detection, or copyright infringement where these "internet user" types of data augmentations are prevalent.

Visual

To see more examples of augmentations, open the Colab notebooks in the README for each modality! (e.g. image README & Colab)

The library is Python-based and requires at least Python 3.6, as we use dataclasses.

Authors

Joanna Bitton — Software Engineer at Meta AI

Zoe Papakipos — Software Engineer at Meta AI

Installation

AugLy is a Python 3.6+ library. It can be installed with:

pip install augly[all]

If you want to only install the dependencies needed for one sub-library e.g. audio, you can install like so:

pip install augly[audio]

Or clone AugLy if you want to be able to run our unit tests, contribute a pull request, etc:

git clone [email protected]:facebookresearch/AugLy.git && cd AugLy
[Optional, but recommended] conda create -n augly && conda activate augly && conda install pip
pip install -e .[all]

Backwards compatibility note: In versions augly<=0.2.1 we did not separate the dependencies by modality. For those versions to install most dependencies you could use pip install augly, and if you want to use the audio or video modalities you would install with pip install augly[av].

In some environments, pip doesn't install python-magic as expected. In that case, you will need to additionally run:

conda install -c conda-forge python-magic

Or if you aren't using conda:

sudo apt-get install python3-magic

Documentation

Check out our documentation on ReadtheDocs!

For more details about how to use each sub-library, how to run the tests, and links to colab notebooks with runnable examples, please see the READMEs in each respective directory (audio, image, text, & video).

Assets

We provide various media assets to use with some of our augmentations. These assets include:

  1. Emojis (Twemoji) - Copyright 2020 Twitter, Inc and other contributors. Code licensed under the MIT License. Graphics licensed under CC-BY 4.0.
  2. Fonts (Noto fonts) - Noto is a trademark of Google Inc. Noto fonts are open source. All Noto fonts are published under the SIL Open Font License, Version 1.1.
  3. Screenshot Templates - Images created by a designer at Facebook specifically to use with AugLy. You can use these with the overlay_onto_screenshot augmentation in both the image and video libraries to make it look like your source image/video was screenshotted in a social media feed similar to Facebook or Instagram.

Links

  1. Facebook AI blog post: https://ai.facebook.com/blog/augly-a-new-data-augmentation-library-to-help-build-more-robust-ai-models/
  2. PyPi package: https://pypi.org/project/augly/
  3. Arxiv paper: https://arxiv.org/abs/2201.06494
  4. Examples: https://github.com/facebookresearch/AugLy/tree/main/examples

Uses of AugLy in the wild

  1. Image Similarity Challenge - a NeurIPS 2021 competition run by Facebook AI with $200k in prizes, currently open for sign ups; also produced the DISC21 dataset, which will be made publicly available after the challenge concludes!
  2. DeepFake Detection Challenge - a Kaggle competition run by Facebook AI in 2020 with $1 million in prizes; also produced the DFDC dataset
  3. SimSearchNet - a near-duplicate detection model developed at Facebook AI to identify infringing content on our platforms

Citation

If you use AugLy in your work, please cite our Arxiv paper using the citation below:

@misc{papakipos2022augly,
  author        = {Zoe Papakipos and Joanna Bitton},
  title         = {AugLy: Data Augmentations for Robustness},
  year          = {2022},
  eprint        = {2201.06494},
  archivePrefix = {arXiv},
  primaryClass  = {cs.AI}}
}

License

AugLy is MIT licensed, as found in the LICENSE file. Please note that some of the dependencies AugLy uses may be licensed under different terms.

augly's People

Contributors

adib234 avatar aghilesazzoug avatar amlarraz avatar amyreese avatar bigfootjon avatar cclauss avatar cloud9c avatar connernilsen avatar dougian avatar facebook-github-bot avatar hazirbas avatar hwangjeff avatar iadityaempire avatar igorsugak avatar jbitton avatar khakhlyuk avatar lyakaap avatar mayaliliya avatar membriux avatar r-barnes avatar singh-sanjay avatar tanujdhiman avatar thatch avatar towzeur avatar zpapakipos 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  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

augly's Issues

Problem using audio augmentations with tensorflow

I tried to use the audio augmentations in a tensorflow project but I had a "Segmentation fault" error in running time while importing the modules.
In my case it can be reproduced only running these two lines:

import tensorflow
import augly.audio as audaugs

Versions:

tensorflow-gpu==2.4.1
augly==0.1.1
Python 3.8.5

Thank you

Other similarities

🚀 Feature

Replace random word with a phonetically similar one.

Or also replace a random word with the same Part Of Speech or lemma (adjective with adjective or run with ran / running etc...)

Motivation

I'm training a transformer based model to spell check utterances (like a reversed augly).
Like Hello r u fin tdy => Hello are you fine today.

I realized that quite often the spelling errors come from phonetically similar words
exemple (not so good exemple but for the sake of the explanation) : "I love jeans" vs "I love gins"

Also, augmenting by replacing with sane pos or other inflections of the same lemma would help in the same direction (as better destroying the sentences to train a better spellchecking model)

Having this kind of built-in Augmentation would help building better models.

Pitch

Having a built-in augmenter that create mistakes not only with levensthein like distances but uses phonetics.
I've done mine using epitran for phonetics and spacy for pos but other frameworks exists.

Alternatives

Implement my own augmenter (done).
Use only text based distances which cannot find jean vs gin or cute vs beautiful or run vs running as they are textually too different but often found in chats.

New feature: bounding boxes augmentation for images

🚀 Feature

Bounding boxes augmentation for images

Motivation

While AugLy makes it very easy to do data augmentation, it's still complicated to do bounding box augmentation that matches the image augmentation.

Pitch

Being able to do data augmentation is a very nice feature to improve ML models. However, it's also necessary to be able to obtain an "augmented bounding box" that's aligned with the augmentation done on the image.

Alternatives

Build your own bounding box augmentation following this tutorial, but too cumbersome.
Search another library that does this automatically.

Additional context

image

Feature Request: Add Lens/Radial Distortions

🚀 Feature

Thank you for his great package. It would be nice to add lens distortion to image transforms.

Motivation

In image augmentation, lens distortion can sometimes be valuable. Spesifically, two separate classes can be added to image.transforms for pincushion and barrel distortions.

image

CI fails on brew install. Error: watchman: no bottle available!

🐛 Bug

CI tests are failing due to

> Run brew install watchman
Error: watchman: no bottle available!
You can try to install from source with:
  brew install --build-from-source watchman
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.
Error: Process completed with exit code 1.

Instagram Filters

Thank you so much for this package. It has some really great augmentations.

aug_image = imaugs.apply_ig_filter(image_path, filter_name="clarendon")

In your image readme it mentions the above function but i don't see it provided in the source. Do you plan on releasing this part of the code?

ReplaceSynonyms functionality

I see ReplaceSynonyms in text/__init__.py, but I don't see that is implemented yet. Are we expecting this functionality any soon?

[MLH Fellow] [Image] Return images in same mode as was passed in

🚀 Feature

Ensure that images are returned from all augmentations in the same mode in which they were passed in

To do

  • Add src_mode arg to ret_and_save_image() in image/utils/utils.py
  • Pass src_mode arg into ret_and_save_image() from every augmentation except convert_color in image/functional.py (e.g. here for apply_lambda)
  • In image test evaluate_class(), assert that the mode of self.img & dst are equal.
  • Run image tests, make sure they all pass: python -m unittest discover -s augly/tests/image_tests/ -p "*"

[BUG] Return type problem in text transformation functions

🐛 Bug

Hello, there seems to be a type issue in the text transformations functions in the augly/text/functional.py file. Indeed, these functions can take a string or a list of strings as inputs, and return a new string or list of strings based on the input type.

textaugs.simulate_typos(["hello"])  # returns a list of strings
textaugs.simulate_typos("hello")  # returns a string

However, all the functions are defined as :

def change_case(
    texts: Union[str, List[str]],
    ...
) -> List[str]:
    pass

Expected behavior

Is it possible to change the types of the functions as something like this to solve this issue :

from typing import TypeVar

T = TypeVar("T", str, List[str])
def change_case(
    texts: T,
    ...
) -> T:
    pass

Environment

  • AugLy Version: 0.2.1
  • Python version: 3.8.5

Audio & video notebooks broken by known colab issue

🐛 Bug

FYI the audio & video notebooks are temporarily broken, giving the following error. I'm going to add a fix to these notebooks today. This is a known issue between colab & torchaudio right now, which it looks like the colab team is working on: googlecolab/colabtools#2417.

Screenshot 2021-11-18 at 14 53 09

To Reproduce

Steps to reproduce the behavior:

  1. Run the audio or video colab notebooks.

Expected behavior

Usually importing the audio/video augly modules works with no error.

[MLH Fellow] [Audio] Add `loop` augmentation

🚀 Feature

Implement a new augmentation called loop which takes in an audio file/numpy array and returns it looped a given n number of times.

To do

  • Read our contributing guidelines for all the steps to add a new augmentation
  • Note: for this augmentation you will also need to define how the matching segments will change here. This should work similarly to how the segments are computed for the video loop augmentation here.
  • Make sure the audio tests (including the new one you have added) pass: python -m unittest discover -s augly/tests/audio_tests/ -p "*"

Is it possible to seed augmentations

🚀 Feature

Checked the code and it doesn't seem possible to seed the augmenters.

Motivation

To reproduce the same augmented test sets.
Also to (deterministically) augment small test sets.

Pitch

Adding the possibility to seed augmenters like My_Augmenter(**my_params, seed=42) which would make reproducible augmentations. Not always the same for all the batch but always in the same order in a reproducible manner.

Alternatives

Don't use augmentation in the test set.

Additional context

I'm working with text, and I would like to augment a test set but the idea also apply to images and audio.

Thanks in advance and thanks a lot for this nice library !

My GNU Grub laptop is locked to Arch

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

Expected behavior

Environment

  • AugLy Version (e.g., 0.1.2):
  • OS (e.g., Linux):
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy):
  • Python version:
  • Other relevant packages (Tensorflow, etc):

Additional context

error importing library in colab

🐛 Bug

when running the colab notebook located in text augmentation folder, after installation and restarting notebook, the following error after calling library import:

NameError                                 Traceback (most recent call last)
<ipython-input-1-3436c02f8201> in <module>()
----> 1 import augly.text as textaugs
      2 
      3 # Define input text
      4 input_text = "Hello, world! How are you today?"
      5 input_text

8 frames
/usr/local/lib/python3.7/dist-packages/nlpaug/model/lang_models/machine_translation_transformers.py in MtTransformers()
     44 
     45     def translate_one_step_batched(
---> 46             self, data, tokenizer: PreTrainedTokenizerBase, model: MarianMTModel
     47     ):
     48         tokenized_texts = tokenizer(data, padding=True, return_tensors='pt')

NameError: name 'PreTrainedTokenizerBase' is not defined

To Reproduce

Steps to reproduce the behavior:

  1. open notebook in https://github.com/facebookresearch/AugLy/tree/main/augly/text
    2.run first cell and then restart colab
  2. run importing augly

Expected behavior

importing library without error

Environment

  • AugLy Version : latest version
  • OS : Linux
  • How you installed AugLy :
    pip install -U augly
    sudo apt-get install python3-magic
  • Python version: 3.7.3

can't fine imaugs.apply_ig_filter in the code

Hi, from the readme file, there is a example as follows:
aug_image = imaugs.apply_ig_filter(image_path, filter_name="clarendon")
but I can't find apply_ig_filter in the source code, could you help me to solve this,thanks

Intensity of zero instead a weighted value

🐛 Bug

Using the color_jitter function for images, if user does not specify a different value than 1.0 to factor parameters, the intensity function will return 0.0, while might return a weighted intensity of the actions did.
The mult_factor_intensity_helper function specifies that if a factor value is 1 the intensity should be 0.0, maybe could be changed to another helper function to create the weighted intensity.

To Reproduce

Steps to reproduce the behavior:

  1. Use an image and the function color_jitter
  2. Give a value to one or two factor parameters

Expected behavior

The intensity value returned in the metadata might be a weighted intensity.

Environment

  • AugLy Version: 0.1.5
  • OS (e.g., Linux): Jupyter notebook
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy): clone

Example

aug_image = imaugs.color_jitter(image_path, brightness_factor=0.5, contrast_factor=1.3, saturation_factor=1.0, output_path=output_path, metadata=meta_color_jitter)

and metadata contains the following info:

'name': 'color_jitter'
'src_width': '640'
'src_height': '426'
'dst_width': '640'
'dst_height': '426'
'output_path': '/content/images/output.png'
'brightness_factor': '0.5'
'contrast_factor': '1.3'
'saturation_factor': '1.0'
'intensity': '0.0'

Example in AugLy_image.ipynb for bounding boxes doesn't work

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

  1. Go to AugLy_image.ipynb and try running the example with the bounded boxes

This is the snippet of code I'm running which is from AugLy_image.ipynb

"""
You can also pass in bounding boxes, which will be transformed along with the 
image & included in the metadata (note: you must provide metadata to get
the transformed bboxes
"""
meta = []
display(
    imaugs.rotate(
        input_img,
        degrees=15,
        metadata=meta,
        bboxes=[(20, 6, 500, 600)],
        bbox_format="pascal_voc",
    )
)
meta

which gives me the following error message

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/var/folders/tb/pj8zr8qn57q8t6cldym25fgw0000gn/T/ipykernel_92443/4056688084.py in <module>
      6 meta = []
      7 display(
----> 8     imaugs.rotate(
      9         input_img,
     10         degrees=15,

TypeError: rotate() got an unexpected keyword argument 'bboxes'

I have to remove arguments bboxes and bboxes_format for this to run without any error messages, which finally gives me this
image

Expected behavior

I expected this to work, or run without any error messages.

Environment

  • AugLy Version (e.g., 0.1.2): 0.1.7
  • OS (e.g., Linux): MacOS
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy): pip install augly
  • Python version: 3.9.6
  • Other relevant packages (Tensorflow, etc): n/a

Additional context

Resizing with single value after padsquare(from augly) gives RuntimeError: stack expects each tensor to be equal size

🐛 Bug

I am facing a bit of a bizzare problem: I have a bunch of different sized images and I am trying to train+infer on these, and I have the following example transform code:

        self.infer_transform = transforms.Compose([
            imaugs.PadSquare(p=1),
            transforms.Resize([384], interpolation=torchvision.transforms.InterpolationMode.BICUBIC),
            transforms.ToTensor(),
            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])

When I use a batchsize >1 I get thrown this:

RuntimeError: stack expects each tensor to be equal size, but got [3, 384, 384] at entry 0 and [3, 385, 384] at entry 3

I find this really bizarre, since, after PadSquare, when I resize using a single int, it should give me a square image back - but it seems like it does not... why is this? is this a bug? It almost seems like some round-off error (got [3, 384, 384] at entry 0 and [3, 385, 384]).

Hoever, if I do this:

        self.infer_transform = transforms.Compose([
            imaugs.PadSquare(p=1),
            transforms.Resize((384,384), interpolation=torchvision.transforms.InterpolationMode.BICUBIC),
            transforms.ToTensor(),
            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])

it works fine...

What is the reason behind this? I am perplexed! When I try out sample images in say colab, they seem to have the same size...

Unfortunately, I am loading some 150k images using imagefolder, so I am not able to inspect the image directly.

`OSError: unknown freetype error` when using `OverlayText`

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

  1. OverlayText with a combination of specific text [166, 287] and specific font (NotoSansBengaliUI-Regular.ttf") results in error.
  2. It appears that even if these two characters (with indices 166 and 287) are separated by any number of other characters, it results in the same error.
# imports
import os
import augly.image as imaugs
import augly.utils as utils
from IPython.display import display

# import paths
from augly.utils.base_paths import (
    EMOJI_DIR,
    FONTS_DIR,
    SCREENSHOT_TEMPLATES_DIR,
)

# read sample input_img
input_img_path = os.path.join(
    utils.TEST_URI, "image", "inputs", "dfdc_1.jpg"
)
input_img = imaugs.scale(input_img_path, factor=0.2)

# This results in error
overlay_text = imaugs.OverlayText(
    text = [166, 287],
    font_file = os.path.join(FONTS_DIR, "NotoSansBengaliUI-Regular.ttf"),
)
overlay_text(input_image)

# These do not result in error
overlay_text = imaugs.OverlayText(
    text = [166],
    font_file = os.path.join(FONTS_DIR, "NotoSansBengaliUI-Regular.ttf"),
)
overlay_text(input_image)

# These do not result in error
overlay_text = imaugs.OverlayText(
    text = [287],
    font_file = os.path.join(FONTS_DIR, "NotoSansBengaliUI-Regular.ttf"),
)
overlay_text(input_image)

# These do not result in error
overlay_text = imaugs.OverlayText(
    text = [166, 287]
   # font_file not specified
)
overlay_text(input_image)

Stack trace:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-74-a3f6c232cffd> in <module>
      3     font_file = os.path.join(FONTS_DIR, "NotoSansBengaliUI-Regular.ttf"),
      4 )
----> 5 overlay_text(input_image)

~/miniconda3/envs/mds572/lib/python3.7/site-packages/augly/image/transforms.py in __call__(self, image, force, metadata)
     48             return image
     49 
---> 50         return self.apply_transform(image, metadata)
     51 
     52     def apply_transform(

~/miniconda3/envs/mds572/lib/python3.7/site-packages/augly/image/transforms.py in apply_transform(self, image, metadata)
    920             x_pos=self.x_pos,
    921             y_pos=self.y_pos,
--> 922             metadata=metadata,
    923         )
    924 

~/miniconda3/envs/mds572/lib/python3.7/site-packages/augly/image/functional.py in overlay_text(image, output_path, text, font_file, font_size, opacity, color, x_pos, y_pos, metadata)
   1121         text=text_str,
   1122         fill=(color[0], color[1], color[2], round(opacity * 255)),
-> 1123         font=font,
   1124     )
   1125 

~/miniconda3/envs/mds572/lib/python3.7/site-packages/PIL/ImageDraw.py in text(self, xy, text, fill, font, anchor, spacing, align, direction, features, language, stroke_width, stroke_fill, embedded_color, *args, **kwargs)
    461             else:
    462                 # Only draw normal text
--> 463                 draw_text(ink)
    464 
    465     def multiline_text(

~/miniconda3/envs/mds572/lib/python3.7/site-packages/PIL/ImageDraw.py in draw_text(ink, stroke_width, stroke_offset)
    416                     ink=ink,
    417                     *args,
--> 418                     **kwargs,
    419                 )
    420                 coord = coord[0] + offset[0], coord[1] + offset[1]

~/miniconda3/envs/mds572/lib/python3.7/site-packages/PIL/ImageFont.py in getmask2(self, text, mode, fill, direction, features, language, stroke_width, anchor, ink, *args, **kwargs)
    668         """
    669         size, offset = self.font.getsize(
--> 670             text, mode, direction, features, language, anchor
    671         )
    672         size = size[0] + stroke_width * 2, size[1] + stroke_width * 2

OSError: unknown freetype error

Expected behavior

I don't know why this combination of text and font does not work. I would expect there to be no error, since overlaying the same text using another font file does not result in error.

Environment

  • AugLy Version (e.g., 0.1.2): 0.1.5
  • OS (e.g., Linux): Ubuntu 20.04
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy): pip install augly
  • Python version: 3.7.9
  • Other relevant packages (Tensorflow, etc):

Additional context

Same error message can be reproduced using the following combinations as well:
text [449, 262] with font file NotoSansThaana-Regular.ttf
text [295, 481] with font file NotoSansBengali-Regular.ttf

Python 3.6 support?

🚀 Feature

Support Python 3.6

Motivation

Python 3.6 is a widely used Python version. Could you add support to it? Or is there any problem to support Python 3.6?

Trim down dependencies, and only pin down minimal version

Related to #65

There seems to be a lot of dependencies in requirements.txt that are actually not needed. For example scikit-learn, numba, joblib, threadpoolctl, six, etc. are not used and could be removed. There are probably a bunch of others, I didn't check them all.

Also, all dependencies are pinned-down to a specific version, e.g. Pillow==8.2.0. Unless there are very specific reasons to do so, it is preferable to only pin down the minimal version e.g. Pillow>=8.2.0 to allow for more flexibility in terms of environment setup.

Python 3.6.2 module 'augly' has no attribute 'image'.

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

conda create -n augly_test python=3.6.2
conda activate augly_test
pip install augly
python -c "import augly.image"

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/__init__.py", line 4, in <module>
    from augly.image.composition import Compose, OneOf
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/composition.py", line 7, in <module>
    from augly.image.transforms import BaseTransform
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/transforms.py", line 8, in <module>
    import augly.image.functional as F
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/functional.py", line 11, in <module>
    import augly.image.utils as imutils
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/utils/__init__.py", line 4, in <module>
    from augly.image.utils.metadata import get_func_kwargs, get_metadata
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/utils/metadata.py", line 7, in <module>
    import augly.image.intensity as imintensity
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/intensity.py", line 6, in <module>
    import augly.image.utils as imutils
AttributeError: module 'augly' has no attribute 'image'

conda install -c conda-forge python-magic
 $ python -c "import augly.image"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/__init__.py", line 4, in <module>
    from augly.image.composition import Compose, OneOf
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/composition.py", line 7, in <module>
    from augly.image.transforms import BaseTransform
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/transforms.py", line 8, in <module>
    import augly.image.functional as F
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/functional.py", line 11, in <module>
    import augly.image.utils as imutils
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/utils/__init__.py", line 4, in <module>
    from augly.image.utils.metadata import get_func_kwargs, get_metadata
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/utils/metadata.py", line 7, in <module>
    import augly.image.intensity as imintensity
  File "/Users/iseessel/anaconda3/envs/augly_test/lib/python3.6/site-packages/augly/image/intensity.py", line 6, in <module>
    import augly.image.utils as imutils
AttributeError: module 'augly' has no attribute 'image'

List of packages:

 $ conda list
# packages in environment at /Users/iseessel/anaconda3/envs/augly_test:
#
# Name                    Version                   Build  Channel
augly                     0.1.9                    pypi_0    pypi
ca-certificates           2021.5.30            h033912b_0    conda-forge
certifi                   2021.5.30        py36h79c6626_0    conda-forge
dataclasses               0.8                      pypi_0    pypi
iopath                    0.1.9                    pypi_0    pypi
libcxx                    12.0.0               h2f01273_0
libedit                   3.1.20210714         h9ed2024_0
libffi                    3.2.1             h0a44026_1007
libmagic                  5.39                 haaf19a9_0    conda-forge
ncurses                   6.2                  h0a44026_1
nlpaug                    1.1.3                    pypi_0    pypi
numpy                     1.19.5                   pypi_0    pypi
openssl                   1.0.2u               h0b31af3_0    conda-forge
pillow                    8.3.2                    pypi_0    pypi
pip                       21.2.2           py36hecd8cb5_0
portalocker               2.3.2                    pypi_0    pypi
python                    3.6.2               hd04bb42_19
python-magic              0.4.24           py36h79c6626_0    conda-forge
python_abi                3.6                     2_cp36m    conda-forge
readline                  7.0                  h1de35cc_5
regex                     2021.9.30                pypi_0    pypi
setuptools                58.0.4           py36hecd8cb5_0
sqlite                    3.33.0               hffcf06c_0
tk                        8.6.11               h7bc2e8c_0
tqdm                      4.62.3                   pypi_0    pypi
wheel                     0.37.0             pyhd3eb1b0_1
xz                        5.2.5                h1de35cc_0
zlib                      1.2.11               h1de35cc_3

Expected behavior

Import Fails. Note: I've tried the same on python3.8.

Environment

  • AugLy Version (e.g., 0.1.2): 0.1.9
  • OS (e.g., Linux): macOS Big Sur (11.6)
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy): See above.
  • Python version: 3.6.2

[MLH Fellow] [Video] Add `augment_audio` augmentation

🚀 Feature

Add an augmentation called augment_audio which takes in a video and an audio augmentation (a Callable), applies the given audio augmentation to the video's audio track, recombines the video with the augmented audio, and writes out the video to the given output path. The metadata should include a field audio_metadata which contains the metadata resulting from applying the audio augmentation on the video's audio track, which means you should call get_metadata() twice -- once for the video, and once for the audio augmentation.

Motivation

One of the cool things about AugLy is that it's multimodal, so users can transform data of different modalities under one unified API, and even apply augmentations to multimodal data (e.g. augment text which is then overlayed over an image which is also augmented, or augment the audio track of a video which is also augmented). In order to make it easier to combine audio & video augmentations, we would like to define a video augmentation which augments the audio with a given AugLy augmentation.

To do

  • Read our contributing guidelines for all the steps to add a new augmentation

InsertEmojis appears in __init__, but nowhere else

🐛 Bug

The init file for text augs mentions an InsertEmoji transform (see here) but that transform is nowhere to be seen in the repo (at least that I could find...)

To Reproduce

Steps to reproduce the behavior:

  1. Check mention of that line
  2. No implementation to be found
  3. :(

Expected behavior

Either fix that line, or better yet if there is an InsertEmoji transform I think folks may find it useful!

[Text] Allow multi words in `misspelling_dict_path`

🚀 Feature

Allow creating typos from multiple words.
Dummy example : "Hello how are you" => "Hello how ru" (are you, two words is being replaced with ru one word)

Motivation

I have a custom homemade logic for it and I wanted to use augly to do the same. However, in French, you can have slang coming from two words like Je suis => Chui (kind of I am => Im)

Pitch

Being able to give a misspelling.json with keys or values containing multiple words.
Mine is already in the good format but the logic is not handled.

Alternatives

Still use my logic on the side but I think it can be useful for many other peoples and use cases.

Additional context

Thanks for the typo adding and splitting words it's really useful !

SpecAugment?

🚀 Feature

Add SpecAugment as a form of audio augmentation.

Motivation

SpecAugment (https://arxiv.org/abs/1904.08779) has resulted in huge improvements in speech recognition performance over the last few years.

Pitch

Any serious audio augmentation toolkit should include SpecAugment as a type of audio augmentation. It has become extremely popular in speech recognition to the point where one wonders about the quality of a research paper that does not use this as standard processing. This, combined with speed and frequency perturbation, has become de rigeur in the speech recognition field. It should be an additional form of processing and accompanied by best practices in applying the technique as there are many variations.

Alternatives

People use time and frequency perturbations by themselves, but when you have a lot of training data, this methodology tends to wash out. SpecAugment improves results even with a lot of training data (at the expense of bigger models).

Additional context

You might also wish to include suggestions for how to integrate AugLy into popular speech recognition toolkits like Kaldi.

Caption Height Error on Meme Format Image Augmentation

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

  1. Load an Image
  2. Use caption height < 10 in: imaugs.meme_format()
  3. See Error

Code

image_path = "data\query\Q00000.jpg"
image = tf.keras.preprocessing.image.load_img(image_path)
image = tf.keras.preprocessing.image.img_to_array(image)
image = tf.keras.preprocessing.image.smart_resize(image, (224,224), interpolation='nearest')
image = tf.keras.preprocessing.image.array_to_img(image)
imaugs.meme_format(image, caption_height=np.random.randint(50),
                            meme_bg_color=tuple(np.random.randint(255, size=3)),
                            text_color=tuple(np.random.randint(255, size=3)),
                            text=meme_text[np.random.randint(len(meme_text))])

Error

Based on the caption height, the function sometimes throws:

imaugs.meme_format(image, caption_height=np.random.randint(50),...
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
c:\Users\name\Documents\Facebook_Challenge\custom.py in 
----> 16 imaugs.meme_format(image, caption_height=np.random.randint(50),
      17                             meme_bg_color=tuple(np.random.randint(255, size=3)),
      18                             text_color=tuple(np.random.randint(255, size=3)),
      19                             text=meme_text[np.random.randint(len(meme_text))])
      20 

~\AppData\Roaming\Python\Python38\site-packages\augly\image\functional.py in meme_format(image, output_path, text, font_file, opacity, text_color, caption_height, meme_bg_color, metadata)
    657     while True:
    658         font = ImageFont.truetype(local_font_path, font_size)
--> 659         text_width, text_height = font.getsize_multiline(text)
    660 
    661         if text_width <= (width - 10) and text_height <= (caption_height - 10):

~\AppData\Roaming\Python\Python38\site-packages\PIL\ImageFont.py in getsize_multiline(self, text, direction, spacing, features, language, stroke_width)
    485         max_width = 0
    486         lines = self._multiline_split(text)
--> 487         line_spacing = self.getsize("A", stroke_width=stroke_width)[1] + spacing
    488         for line in lines:
    489             line_width, line_height = self.getsize(

~\AppData\Roaming\Python\Python38\site-packages\PIL\ImageFont.py in getsize(self, text, direction, features, language, stroke_width)
    428         # vertical offset is added for historical reasons
    429         # see https://github.com/python-pillow/Pillow/pull/4910#discussion_r486682929
--> 430         size, offset = self.font.getsize(text, "L", direction, features, language)
    431         return (
    432             size[0] + stroke_width * 2,

OSError: invalid argument

Expected behavior

return the PIL.Image.Image

Environment

  • AugLy Version (e.g., 0.1.2): 0.1.3
  • OS (e.g., Linux): Windows
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy): pip
  • Python version: 3.8.8
  • Other relevant packages (Tensorflow, etc): Tensorflow

Additional context

When caption height is below 10 augly throws the error
Possibly show a warning instead.

AttributeError: module 'augly' has no attribute 'audio'

🐛 Bug

Traceback (most recent call last):
File "video_aug.py", line 3, in
import augly.video as vidaugs
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/video/init.py", line 4, in
from augly.video.composition import Compose, OneOf
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/video/composition.py", line 8, in
from augly.video.helpers import validate_input_and_output_paths
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/video/helpers/init.py", line 4, in
from augly.video.helpers.ffmpeg import (
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/video/helpers/ffmpeg.py", line 10, in
import augly.audio.utils as audutils
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/audio/init.py", line 4, in
from augly.audio.composition import Compose, OneOf
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/audio/composition.py", line 8, in
from augly.audio.transforms import BaseTransform
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/audio/transforms.py", line 7, in
import augly.audio.functional as F
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/audio/functional.py", line 8, in
import augly.audio.utils as audutils
File "/root/anaconda3/envs/zyj/lib/python3.6/site-packages/augly/audio/utils.py", line 7, in
import augly.audio.intensity as audintensity
AttributeError: module 'augly' has no attribute 'audio'

To Reproduce

Steps to reproduce the behavior:

1.install augly
2.run sample code import augly.video as vidaugs
3. error occured.

Environment

  • AugLy Version (0.1.10):
  • OS centos 7
  • How I installed AugLy
    pip install augly[av]
    conda install -c conda-forge python-magic
  • Python version: 3.6

How to use AugLy in detectron2?

I suppose AugLy is a full featured augmentation lib? So that some technics such as MixUp, CutMix will also support and use in detectron2?

Problem with open font file

Hi! I'm testing your library (concretely the text part) with spanish language following this examplea . In this process the library throws me an error when it tries to open the fonts file because an encoding problem (It can't understand some characters).

I've changed this line by: with open(local_fonts_path, encoding='utf-8') as text_file: and it works.

Group dependencies as setup.py extras

🚀 Feature

Grouping library dependencies in setup.py by modality.

Motivation

If we are going to apply augmentations on just one modality, we shouldn't install all library dependencies needed to augment other modalities.

Pitch

Use extras_require in setup.py to specify software dependencies that are required for each modality. For example, installing audio only dependencies with augly[audio]. Have an [all] option that installs all dependencies.

Merge words

🚀 Feature

Like "Hello I really like Augly" => "Hello I reallylike Augly"

Motivation

The same as splitWord, it's nice to train language models, spellcheckers etc....

Pitch

Having a class/function as split word but to randomly merge words

Alternatives

Implement a custom logic.
Use only split words

Additional context

I'm trying to train a spell checker with really hard slangs and it's one of my use cases.

Thanks a lot !
Have a great day

`OverlayStripes()` modifies the input image

🐛 Bug

OverlayStripes() modifies the input image

To Reproduce

Steps to reproduce the behavior:

  1. Create an instance of OverlayStripes() transform
  2. Call transform on an input image
  3. Display the input image
import os
import augly.image as imaugs
import augly.utils as utils
from IPython.display import display

input_img_path = os.path.join(
    utils.TEST_URI, "image", "inputs", "dfdc_1.jpg"
)
input_img = imaugs.scale(input_img_path, factor=0.2)
display(input_img)

display(imaugs.OverlayStripes()(input_img))

display(input_img)

Expected behavior

I believe OverlayStripes() should create a modified copy of the input image without modifying the input image directly. This behaviour would be consistent with other similar methods such as OverlayOntoScreenshot(), OverlayEmoji(), and OverlayText().

Environment

  • AugLy Version (e.g., 0.1.2): 0.1.5
  • OS (e.g., Linux): Linux Ubuntu 20.04
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy): pip install augly
  • Python version: Python 3.7.9
  • Other relevant packages (Tensorflow, etc):

Additional context

New Feature ::::: Add a new function of Resample Audio

🚀 Feature

Hello everybody, I want to add a new function in audio augmentations to resample the audio.

Motivation

This is a great function and I found most of the guys are not able to resample audio through so by this Augly which is specially for augmentations so we can provide this function to users for our best case.

Pitch

Resampling audio means increase or decrease the sample rate of audio. For example audio has sample rate from 22050 to 44100.

Alternatives

  • Loading audio file
  • Taking target sample rate from user
  • Apply augmentation

Error in Installing

🐛 Bug

augly

To Reproduce

Steps to reproduce the behavior:

  1. Please do the scipy --version from 1.6.2 to 1.5.4

Expected behavior

Environment

  • AugLy Version (e.g., 0.1.2): 0.1.3
  • OS (e.g., Linux): Windows
  • How you installed AugLy (pip install augly, clone & pip install -e AugLy): pip install wheel-name
  • Python version: 3.7
  • Other relevant packages (Tensorflow, etc):

Additional context

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.