
Train a model with TensorFlow to generate cube vertex coordinates from Python data and render a 3D Blender figure from the results.
Create training data for the model by scripting automatic coordinates for the cube's vertex positions, using random values to reflect equal distances, and save the results in a json file.
Create a python script to generate 3d cube vertices from random samples inside a for loop using enumerate, scale to 1–10, and save to cube_data.json using json and numpy.
Create and inspect cube vertex data by generating cube_data.json, then sort the coordinates of the vertices to visualize each cube's coordinate arrays more clearly.
Learn how a generative adversarial network trains a generator and a discriminator to reproduce cube coordinates, with the model unaware of what it creates yet learning to build a cube.
Import json and TensorFlow, load cube_data.json into data, convert to tensor, and build train_dataset using from_tensor_slices and batch with 32 for efficient model training.
Build a generator model to produce cube coordinates from a 100-dimensional latent space. Use Sequential network with dense layers and leaky relu to reshape into 8x3 coordinates for 3d figures.
Create a discriminator that distinguishes real from generated data using Conv1D layers with 32 and 64 filters, LeakyReLu activations, Flatten, Dense with 1 neuron, and a sigmoid output.
Compile the generator and discriminator with Adam optimizers, set learning_rate 0.0002 and beta_1 0.5, and define generator_loss and discriminator_loss using binary_crossentropy, ones_like, and zeros_like.
Construct a training loop for a gan with for loops over num_epochs and train_dataset, using tf.GradientTape to update the discriminator and generator with real_data_batch, generated_data_batch, and noise.
Train models to generate eight coordinates representing a cube. Print the generated tensor to the console and convert to a numpy array with tolist for Blender visualization.
Generate a cube in blender from model-produced coordinates by running a GAN script via a subprocess, and use the bpy library to access blender elements to create the figure.
Learn to write a blender script in vscode using bpy, subprocess, and json to create a mesh, link it to a collection, and build a 3D figure from vertex data.
Obtain cube generator data, set script_path, and run the generator via subprocess.run using python3.9. Parse stdout with json.loads to fill my_verts and my_faces, then run in Blender to generate figures.
Run a Blender script to generate a figure and observe how training data and epochs shape vertex coordinates, biasing toward cubes with more data and epochs.
Execute a Blender script in the scripting view to generate 3d coordinates from 100 cubes using 100 epochs, then compare multiple figures in layout to refine the cube form.
Increase num_epochs to 300 to let the model learn from 100 cubes, run the Blender script, and compare results as figures become more cube-like.
We modify the script to generate 500 data points, set num_epochs to 100, run the Blender script, observe distorted cube figures, and plan to increase epochs in the next video.
Increase num_epochs to 300 and run the Blender script on 500 elements, then switch to layout to compare results. Notice cube-like figures with a generally stable structure and fewer distortions.
Modify the script to export coordinates without training, run in Blender, and observe that the generated figures remain random and far from cube-shaped, highlighting quick testing without training.
Apply what you learned to build models that learn to generate the information needed to create 3d figures.
Hello and welcome.
If you are a Python developer who wants to learn about AI and apply it in very simple examples, this course is for you.
This course focuses on creating a Generative Adversarial Network that will learn to create the vertices of a 3D figure.
For this we will use Python, Tensorflow and Blender.
With Python, we will create several scripts. One that will help us to create the training information, another one that will use Tensorflow to create the Generative Adversarial Networks and finally, one that will be executed in blender to create a 3D figure with the information created by the AI.
At the end, we will visualize and compare the results so we can make adjustments and improve performance.
I hope you find the content useful and that you can apply it to your personal projects.
Have fun and happy learning.
What will students learn in your course?
Learn to create a basic Generative Adversarial Networks.
Use Machine learning to create basic 3D models.
Create your own training data.
Call external script from Blender using a sub process.
What are the requirements or prerequisites for taking your course?
Python 3.9
Blender 3.X
Tensorflow libraries
Visual Studio Code
Who is this course for?
Software developers that want to learn about AI