import bpy
# Delete all objects
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Add a cube
bpy.ops.mesh.primitive_cube_add(location=(0,4,0), rotation=(0, 0, 0.7))
cube = bpy.context.active_object
# Add a material
cube.active_material = bpy.data.materials.new(name="MaterialName")
cube.active_material.diffuse_color = (1, 0, 0, 1)
# Add a camera
bpy.ops.object.camera_add(location=(0, -50, 0), rotation=(3.14 / 2, 0, 0))
bpy.context.scene.camera = bpy.context.active_object
# Add a light
bpy.ops.object.light_add(type='SUN')
# Render image
bpy.context.scene.render.resolution_x = 100
bpy.context.scene.render.resolution_y = 100
bpy.context.scene.render.filepath = '/path/to/render.png'
bpy.ops.render.render(write_still=True)
(0_3_1_6.png)
import random
random.randint(0, 10) # Random integer between 0 and 10
random.uniform(-3, 3) # Random float between -3 and 3
random.choice(['red', 'green', 'blue']) # Random choice from the list
import bpy
# Delete all objects
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Import the model in FBX format
bpy.ops.import_scene.fbx(filepath="/path/to/model.fbx")
imported_object = bpy.context.selected_objects[0]
imported_object.location = (0, 0, 0)
imported_object.rotation_euler = (0, 0, 0)
imported_object.scale = (4, 4, 4)
# Add a camera
bpy.ops.object.camera_add(location=(0, -50, 0), rotation=(3.14 / 2, 0, 0))
bpy.context.scene.camera = bpy.context.active_object
# Add a light
bpy.ops.object.light_add(type='SUN', location=(0, 0, 0), rotation=(0, 0, 0))
# Background plane
bpy.ops.mesh.primitive_plane_add(size=2, location=(0, 60, 0), rotation=(3.14/2, 0, 0))
plane = bpy.context.active_object
plane.scale = (120, 120, 120)
mat = bpy.data.materials.new("BGMaterial")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
for node in nodes:
nodes.remove(node)
tex_node = nodes.new("ShaderNodeTexImage")
emit_node = nodes.new("ShaderNodeEmission")
out_node = nodes.new("ShaderNodeOutputMaterial")
tex_node.image = bpy.data.images.load("/path/to/background.png")
links.new(tex_node.outputs["Color"], emit_node.inputs["Color"])
links.new(emit_node.outputs["Emission"], out_node.inputs["Surface"])
plane.data.materials.append(mat)
# Render image
bpy.context.scene.render.resolution_x = 256
bpy.context.scene.render.resolution_y = 256
bpy.context.scene.render.filepath = "/path/to/render.png"
bpy.ops.render.render(write_still=True)
# Remove orphan data
for block in bpy.data.meshes:
if block.users == 0:
bpy.data.meshes.remove(block)
for block in bpy.data.materials:
if block.users == 0:
bpy.data.materials.remove(block)
for block in bpy.data.images:
if block.users == 0:
bpy.data.images.remove(block)
(0_lion.png)
Use the provided backgrounds and 3D models
Send your best synthetic images to workshop@enricmor.eu
import torch
from torch.utils.data import Dataset
class MyDataset(Dataset):
def __init__(self):
super().__init__()
self.images = torch.randn(1000, 3, 256, 256)
self.labels = torch.randint(0, 2, (1000,))
def __getitem__(self, index):
return self.images[index], self.labels[index]
def __len__(self):
return len(self.images)
from torch.utils.data import random_split
dataset = MyDataset()
train_size = int(0.8 * len(dataset))
val_size = len(dataset) - train_size
train_dataset, val_dataset = random_split(dataset, [train_size, val_size])
from torch.utils.data import DataLoader
train_loader = DataLoader(train_dataset, batch_size=32, shuffle=True, num_workers=4)
val_loader = DataLoader(val_dataset, batch_size=32, shuffle=False, num_workers=4)
import torchvision
import torch.nn as nn
model = torchvision.models.resnet18()
model.fc = nn.Linear(model.fc.in_features, 3)
import torch.optim as optim
optimizer = optim.SGD(model.parameters(), lr=1e-3)
import torch.nn as nn
criterion = nn.CrossEntropyLoss()
model.train()
num_epochs = 5
for epoch in range(num_epochs):
for batch_data, batch_labels in train_loader:
outputs = model(batch_data)
loss = criterion(outputs, batch_labels)
optimizer.zero_grad()
loss.backward()
optimizer.step()
Complete the missing components:
Introduction to synthetic data
Hello Blender
Savanna dataset
Image classifier
Improve the following components:
Albumentations: https://albumentations.ai/
Gatys, Leon A. "A neural algorithm of artistic
style." arXiv preprint arXiv:1508.06576 (2015)
Send your best stylized images to workshop@enricmor.eu
Source: Wikipedia
Moskát, Csaba, et al. "Cuckoo parasitism on two
closely-related Acrocephalus warblers in distant areas: a case of parallel coevolution?." Avian
Research 3.4 (2012): 320-329.
Revi, Remya, K. R. Vidya, and M. Wilscy.
"Detection of deepfake images created using generative adversarial networks: A review." Second
International Conference on Networks and Advances in Computational Technologies: NetACT 19.
Springer International Publishing, 2021.
Shrivastava, Ashish, et al. "Learning from
simulated and unsupervised images through adversarial training." Proceedings of the IEEE
conference on computer vision and pattern recognition. 2017.
Hello Blender
Pytorch introduction
Domain randomization
Data augmentation
Style transfer
Domain adaptation
Generative networks
CycleGAN