API
VisualAtom.PERMVisualAtom.AtomVisualAtom.AtomVisualAtom.ConfigVisualAtom.ConfigVisualAtom.generate_instancesVisualAtom.pnoise1VisualAtom.render!VisualAtom.save_imagesVisualAtom.uniform
VisualAtom.PERM — Constanthttps://github.com/caseman/noise/blob/bb32991ab97e90882d0e46e578060717c5b90dc5/_noise.h#L29-L61
VisualAtom.Atom — TypeAtom(config::Config)
Atom([rng=GLOBAL_RNG], config::Config)Atom struct representing the data structure proposed in Visual Atoms: Pre-training Vision Transformers with Sinusoidal Waves.
Arguments
config::Config: A configuration object containing the parameter ranges.
Returns
Atom: A newAtominstance with randomly generated properties.
VisualAtom.Atom — MethodAtom(rng::AbstractRNG, config::Config)Arguments
rng::AbstractRNG: The random number generator to be used.config::Config: A configuration object containing the parameter ranges.
Returns
Atom: A newAtominstance with randomly generated properties.
VisualAtom.Config — TypeConfigA struct representing the configuration for generating atom instances and images.
VisualAtom.Config — MethodConfig(config_path::AbstractString)Create a new Config instance by reading and parsing the configuration file at the specified config_path.
Arguments
config_path::AbstractString: Path to the configuration file (TOML format).
Returns
Config: A newConfiginstance with properties read from the configuration file.
VisualAtom.generate_instances — Methodgenerate_instances(config::Config; save_root::AbstractString, category_id::Int, num_instances::Int)Generate instances of Atom images based on the configuration object andsave them to the specified directory. The images will be saved in a subdirectory named after the category ID.
Arguments
config::Config: The configuration object containing parameter ranges for the Atom generation.save_root::AbstractString: The root directory where the images will be saved.category_id::Int: The category ID, used for generating the seed and naming the output subdirectory.num_instances::Int: The number of instances (images) to generate and save.
Returns
- This function does not return a value; it saves generated images to the specified directory.
VisualAtom.pnoise1 — Methodpnoise1(x)Perlin noise – pure Julia implementation. The results of this computation are consistent with the Python package's noise.pnoise1 function.
VisualAtom.render! — Methodrender!(rng::AbstractRNG, atom::Atom, canvas::AbstractMatrix)Render an atom onto a canvas, modifying the canvas in-place. The atom's properties and a random number generator are used to generate the image.
Arguments
rng::AbstractRNG: The random number generator to be used.atom::Atom: The atom instance with properties defining its appearance.canvas::AbstractMatrix: The canvas (matrix of color values) onto which the atom will be rendered.
Returns
canvas::AbstractMatrix: The modified canvas with the rendered atom.
VisualAtom.save_images — Methodsave_images(rng::AbstractRNG, atom::Atom; save_dir::AbstractString, num_instances::Int, H::Int, W::Int)Render and save images of the Atom instance atom onto a canvas with specified dimensions. The images will be saved in the specified directory.
Arguments
rng::AbstractRNG: The random number generator to be used.atom::Atom: The atom instance with properties defining its appearance.save_dir::AbstractString: The directory where the images will be saved.num_instances::Int: The number of instances (images) to generate and save.H::Int: The height of the canvas.W::Int: The width of the canvas.
Returns
- This function does not return a value; it saves generated images to the specified directory.
VisualAtom.uniform — Methoduniform([rng=GLOBAL_RNG], a::T, b::T) where {T<:AbstractFloat}
uniform([rng=GLOBAL_RNG], a::Real, b::Real)Generate a random number in the interval [a, b), uniformly distributed, using the provided random number generator rng. The arguments a and b must be of the same subtype of AbstractFloat.
Arguments
rng::AbstractRNG: The random number generator to be used.a::T: The lower bound of the interval (inclusive).b::T: The upper bound of the interval (exclusive).
Returns
T: A random number in the interval [a, b).