Code Monkey home page Code Monkey logo

Comments (3)

zpapakipos avatar zpapakipos commented on September 23, 2024 2

Hi @ierezell, thanks for this request! We currently have a seed arg for some augmentations that include random sampling within them (e.g. change_case in text https://github.com/facebookresearch/AugLy/blob/main/augly/text/functional.py#L65 or perspective_transform in image https://github.com/facebookresearch/AugLy/blob/main/augly/image/functional.py#L1719), but it's true that this is missing for some (e.g. insert_punctuation_chars in text https://github.com/facebookresearch/AugLy/blob/main/augly/text/functional.py#L144).

I will add this to our list of tasks to do soon, to add seed args to all augmentations that involve random sampling which don't already have it.

from augly.

sciencecw avatar sciencecw commented on September 23, 2024

It is good that change_case has seed argument, but the current implementation means that without specifying the seed, it keeps generating the same result

from augly.

javiabellan avatar javiabellan commented on September 23, 2024

AugLy is cool, however many transformations are not random:

Here is a code snippet to make any transfomation random, (even with the random distributions you preffer):

import numpy as np
import augly.image as imaugs
    
def random_uniform(min,max):
    return lambda: np.random.uniform(min, max)
    
def random_normal(mean,std):
    return lambda: np.random.normal(mean, std)

def randomize(fn_2_randomize, **kwargs):
    def randomized_fn(img_pil):
        # 1) Compute random_params into fixed_params:
        fixed_args = {}
        for key_paramName, value_randomFn in kwargs.items():
            fixed_args[key_paramName] = value_randomFn()
        # 2) Call PIL function with fixed_params
        return fn_2_randomize(img_pil, **fixed_args)
    return randomized_fn

random_overlay_text = randomize(imaugs.overlay_text,
                                x_pos=random_uniform(0,0.5),
                                y_pos=random_uniform(0,0.9))

# Now you can call it :)
random_overlay_text(img)

from augly.

Related Issues (20)

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.