Skip to content

Add Craftman #234

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

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ cython_debug/

# Ignore test outputs
outputs/
output/

# Ignore folders only used for build dependencies
_Pre_Builds/_Build_Dependencies
_Pre_Builds/_Build_Wheels
_Pre_Builds/_Libs

models/
output/

.idea
143 changes: 143 additions & 0 deletions Configs/Craftsman_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: michelangelo-image-to-shape-diffusion/clip-mvrgb-modln-l256-e64-ne8-nd16-nl6-170k
description: ''
tag: michelangelo-aligned-autoencoder+n4096+noise0.0+pfeat3+zeroemb0.0+normembFalse+lr5e-05+qkvbiasFalse+nfreq8+ln_postTrue
seed: 0
use_timestamp: true
timestamp: ''
exp_root_dir: outputs
exp_dir: outputs/michelangelo-image-to-shape-diffusion/clip-mvrgb-modln-l256-e64-ne8-nd16-nl6-170k
trial_name: michelangelo-aligned-autoencoder+n4096+noise0.0+pfeat3+zeroemb0.0+normembFalse+lr5e-05+qkvbiasFalse+nfreq8+ln_postTrue
trial_dir: outputs/michelangelo-image-to-shape-diffusion/clip-mvrgb-modln-l256-e64-ne8-nd16-nl6-170k/michelangelo-aligned-autoencoder+n4096+noise0.0+pfeat3+zeroemb0.0+normembFalse+lr5e-05+qkvbiasFalse+nfreq8+ln_postTrue
n_gpus: 8
resume: ./ckpts/3DNativeGeneration/michelangelo-image-to-shape-diffusion/clip-mvrgb-modln-l256-e64-ne8-nd16-nl6-170k.ckpt
data_type: objaverse-datamodule
data:
root_dir: data/objaverse_clean/cap3d_high_quality_170k_images
data_type: occupancy
n_samples: 4096
noise_sigma: 0.0
load_supervision: false
supervision_type: occupancy
n_supervision: 10000
load_image: true
image_data_path: data/objaverse_clean/raw_data/images/cap3d_high_quality_170k
image_type: mvrgb
idx:
- 0
- 4
- 8
- 12
- 16
n_views: 4
load_caption: false
rotate_points: false
batch_size: 32
num_workers: 16
system_type: shape-diffusion-system
system:
val_samples_json: val_data/mv_images/val_samples_rgb_mvimage.json
z_scale_factor: 1.0
guidance_scale: 7.5
num_inference_steps: 50
eta: 0.0
shape_model_type: michelangelo-aligned-autoencoder
shape_model:
num_latents: 256
embed_dim: 64
point_feats: 3
out_dim: 1
num_freqs: 8
include_pi: false
heads: 12
width: 768
num_encoder_layers: 8
num_decoder_layers: 16
use_ln_post: true
init_scale: 0.25
qkv_bias: false
use_flash: true
use_checkpoint: true
condition_model_type: clip-embedder
condition_model:
pretrained_model_name_or_path: openai/clip-vit-large-patch14
encode_camera: true
camera_embeds_dim: 32
n_views: 4
empty_embeds_ratio: 0.1
normalize_embeds: false
zero_uncond_embeds: true
denoiser_model_type: simple-denoiser
denoiser_model:
input_channels: 64
output_channels: 64
n_ctx: 256
width: 768
layers: 6
heads: 12
context_dim: 1024
init_scale: 1.0
skip_ln: true
use_checkpoint: true
noise_scheduler_type: diffusers.schedulers.DDPMScheduler
noise_scheduler:
num_train_timesteps: 1000
beta_start: 0.00085
beta_end: 0.012
beta_schedule: scaled_linear
variance_type: fixed_small
clip_sample: false
denoise_scheduler_type: diffusers.schedulers.DDIMScheduler
denoise_scheduler:
num_train_timesteps: 1000
beta_start: 0.00085
beta_end: 0.012
beta_schedule: scaled_linear
clip_sample: false
set_alpha_to_one: false
steps_offset: 1
loggers:
wandb:
enable: false
project: JiangXin
name: text-to-shape-diffusion+michelangelo-image-to-shape-diffusion/clip-mvrgb-modln-l256-e64-ne8-nd16-nl6-170k+michelangelo-aligned-autoencoder+n4096+noise0.0+pfeat3+zeroemb0.0+normembFalse+lr5e-05+qkvbiasFalse+nfreq8+ln_postTrue
loss:
loss_type: mse
lambda_diffusion: 1.0
optimizer:
name: AdamW
args:
lr: 5.0e-05
betas:
- 0.9
- 0.99
eps: 1.0e-06
scheduler:
name: SequentialLR
interval: step
schedulers:
- name: LinearLR
interval: step
args:
start_factor: 1.0e-06
end_factor: 1.0
total_iters: 5000
- name: CosineAnnealingLR
interval: step
args:
T_max: 5000
eta_min: 0.0
milestones:
- 5000
trainer:
num_nodes: 2
max_epochs: 100000
log_every_n_steps: 5
num_sanity_val_steps: 1
check_val_every_n_epoch: 3
enable_progress_bar: true
precision: 16-mixed
strategy: ddp_find_unused_parameters_true
checkpoint:
save_last: true
save_top_k: -1
every_n_train_steps: 5000
2 changes: 1 addition & 1 deletion Gen_3D_Modules/CharacterGen/Stage_3D/lrm/models/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _compute_vertex_normal(self):
v1 = self.v_pos[i1, :]
v2 = self.v_pos[i2, :]

face_normals = torch.cross(v1 - v0, v2 - v0)
face_normals = torch.cross(v1 - v0, v2 - v0, dim=-1)

# Splat face normals to vertices
v_nrm = torch.zeros_like(self.v_pos)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def compute_vertex_normal(v_pos, t_pos_idx):
v1 = v_pos[i1, :]
v2 = v_pos[i2, :]

face_normals = torch.cross(v1 - v0, v2 - v0)
face_normals = torch.cross(v1 - v0, v2 - v0, dim=-1)

# Splat face normals to vertices
v_nrm = torch.zeros_like(v_pos)
Expand Down
6 changes: 3 additions & 3 deletions Gen_3D_Modules/Unique3D/mesh_reconstruction/remesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ def flip_edges(
e1 = v[:,1]
cl = v[:,2]
cr = v[:,3]
n = torch.cross(e1,cl) + torch.cross(cr,e1) #sum of old normal vectors
flip.logical_and_(torch.sum(n*torch.cross(cr,cl),dim=-1)>0) #first new face
flip.logical_and_(torch.sum(n*torch.cross(cl-e1,cr-e1),dim=-1)>0) #second new face
n = torch.cross(e1,cl,dim=-1) + torch.cross(cr,e1,dim=-1) #sum of old normal vectors
flip.logical_and_(torch.sum(n*torch.cross(cr,cl,dim=-1),dim=-1)>0) #first new face
flip.logical_and_(torch.sum(n*torch.cross(cl-e1,cr-e1,dim=-1),dim=-1)>0) #second new face

flip_edges_neighbors = edges_neighbors[flip] #E",4
flip_edge_to_face = edge_to_face[candidates,:,0][flip] #E",2
Expand Down
52 changes: 52 additions & 0 deletions Gen_3D_Modules/craftsman/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import importlib

__modules__ = {}


def register(name):
def decorator(cls):
if name in __modules__:
raise ValueError(
f"Module {name} already exists! Names of extensions conflict!"
)
else:
__modules__[name] = cls
return cls

return decorator


def find(name):
if name in __modules__:
return __modules__[name]
else:
try:
module_string = ".".join(name.split(".")[:-1])
cls_name = name.split(".")[-1]
module = importlib.import_module(module_string, package=None)
return getattr(module, cls_name)
except Exception as e:
raise ValueError(f"Module {name} not found!")


### grammar sugar for logging utilities ###
import logging

logger = logging.getLogger("pytorch_lightning")

from pytorch_lightning.utilities.rank_zero import (
rank_zero_debug,
rank_zero_info,
rank_zero_only,
)

debug = rank_zero_debug
info = rank_zero_info


@rank_zero_only
def warn(*args, **kwargs):
logger.warn(*args, **kwargs)


from . import data, models, systems
3 changes: 3 additions & 0 deletions Gen_3D_Modules/craftsman/data/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import (
objaverse
)
Loading