Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random fitness based individual generator and image generation #4

Closed
FrancoYudica opened this issue Dec 2, 2024 · 3 comments
Closed

Comments

@FrancoYudica
Copy link
Owner

FrancoYudica commented Dec 2, 2024

Now that the main components are ready:

  • MSE (as fitness function)
  • Average color sampler
  • Individual
  • Individual renderer

It is now possible to implement a simple individual generation algorithm, which will allow me to test how all the previous components interact and function together.

@FrancoYudica
Copy link
Owner Author

FrancoYudica commented Dec 2, 2024

Random fitness based algorithm:

  1. Starts by creating a set of random individuals where all it's attributes are randomized.
  2. For each individual
  • The average color is sampled from the target texture.
  • Individual is rendered over source texture.
  • Individual fitness is calculated with the output of the previous render and target texture, using a fitness calculator metric such as MSE.
  1. Returns the fittest individual.

Image generation:

After implementing the random fitness-based individual generation algorithm, I proceeded to develop the image generation algorithm. This algorithm iteratively executes the individual generation process, continuously feeding its output back into the individual generation algorithm after each individual is created. This cycle continues until the desired number of individuals is generated.
The output is an image with n number of individuals.

@FrancoYudica
Copy link
Owner Author

FrancoYudica commented Dec 2, 2024

Testing image generation

Got some promising results with this simple algorithm:

Screenshot from 2024-12-02 10-28-55

The first render with 2,000 individuals took 2 minutes and 47 seconds. For this example, I used the non-masked average color sampler.
For each individual added to the image, 100 individuals were tested using the previously discussed random fitness-based algorithm. This resulted in a total of 200,000 individuals tested over 167,000 ms, with an average processing time of 1.2 ms per individual. These results clearly demonstrate the effectiveness of the GPU optimizations.

@FrancoYudica
Copy link
Owner Author

FrancoYudica commented Dec 2, 2024

Testing image generation with masked color sampler

Decided to test the masked average color sampler with the same settings.

Screenshot from 2024-12-02 10-39-45
This method produces a sharper result compared to the initial render, preserving more details. Additionally, the colors are noticeably more accurate.

The downside of this technique is that the mask texture must be rendered before performing masked average color sampling. This requires an additional rendering pass prior to color sampling, effectively doubling the rendering time and slowing down individual generation by approximately 20–40%.

@FrancoYudica FrancoYudica changed the title Random fitness based individual generation Random fitness based individual generator and image generation Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant