This model is a lightweight, pixel-space diffusion model trained to generate 64x64 RGBA Minecraft skin textures directly from natural language prompts or structured tag streams.
Unlike conventional latent diffusion pipelines (e.g., Stable Diffusion), this model does not use a VAE. It operates directly in the discrete 64x64 RGBA pixel coordinate space, preserving hard-edged pixel art boundaries and the multi-layer skin format (Base layer + Outer overlay) ready for in-game use.
The model was developed via a two-stage pretraining and fine-tuning strategy:
Stage 1 (Unconditional / Class-Conditional Pretraining):
UNet2DModel (~35M parameters, $64 \times 64 \times 4$ RGBA input/output).MihaiPopa-1/minecraft-skins-1.1m-deduped-64x64-1.5) to thoroughly learn Minecraft UV geometry, limb symmetries, and pixel art shading techniques.classic (4px Steve arms) and slim (3px Alex arms).Stage 2 (Text-Conditioned Full Fine-Tuning):
zhoudoe23/siglip-so400m-mcskin-fused (SigLIP-So400M fine-tuned on Minecraft UV maps, 1152-dim text embeddings).attn2) were fully unfrozen and trained end-to-end with dynamic weighted prompt sampling and Classifier-Free Guidance (CFG).This model is an experimental community project and has clear limitations inherent to continuous diffusion operating on discrete low-resolution pixel grids:
import torch
import numpy as np
from PIL import Image
from diffusers import UNet2DConditionModel, DPMSolverSinglestepScheduler
from transformers import AutoTokenizer, SiglipTextModel
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
MODEL_ID = "zhoudoe23/MCDiffusion-35M"
SIGLIP_ID = "zhoudoe23/siglip-so400m-mcskin-fused"
# 1. Load Models
unet = UNet2DConditionModel.from_pretrained(MODEL_ID, torch_dtype=torch.float16).to(DEVICE)
unet.eval()
tokenizer = AutoTokenizer.from_pretrained(SIGLIP_ID)
text_model = SiglipTextModel.from_pretrained(SIGLIP_ID, torch_dtype=torch.float16).to(DEVICE)
text_model.eval()
# 2. Setup DPM-Solver++ 2S Scheduler
scheduler = DPMSolverSinglestepScheduler(
num_train_timesteps=1000,
beta_start=0.0001,
beta_end=0.02,
beta_schedule="linear",
algorithm_type="dpmsolver++",
solver_order=2,
)
scheduler.set_timesteps(25, device=DEVICE)
# 3. Prompt Setup
prompt = "bright green eyes, pale face, long pink hair, cat ears, black cat hoodie, white skirt"
negative_prompt = "faceless, no eyes, blind, blurry face, flat skin"
model_type = "slim" # "classic" (4px arms) or "slim" (3px arms)
with torch.no_grad():
cond_inputs = tokenizer([prompt], padding="max_length", max_length=64, truncation=True, return_tensors="pt").to(DEVICE)
cond_emb = text_model(**cond_inputs).last_hidden_state
neg_inputs = tokenizer([negative_prompt], padding="max_length", max_length=64, return_tensors="pt").to(DEVICE)
uncond_emb = text_model(**neg_inputs).last_hidden_state
text_embs = torch.cat([uncond_emb, cond_emb], dim=0)
class_id = 1 if model_type == "slim" else 0
class_labels = torch.tensor([class_id, class_id], device=DEVICE)
# 4. Latent Sampling (with Clamping for stability)
g = torch.Generator(device=DEVICE).manual_seed(42)
raw_latents = torch.randn((1, 4, 64, 64), generator=g, device=DEVICE, dtype=torch.float16)
latents = raw_latents.clamp(-2.5, 2.5) # Clean outlier noise
guidance_scale = 3.0
with torch.no_grad():
for t in scheduler.timesteps:
latent_input = torch.cat([latents] * 2)
noise_pred = unet(latent_input, t, encoder_hidden_states=text_embs, class_labels=class_labels).sample
uncond, text = noise_pred.chunk(2)
noise_pred = uncond + guidance_scale * (text - uncond)
latents = scheduler.step(noise_pred, t, latents).prev_sample
# 5. Export 64x64 RGBA Skin Texture
samples = ((latents.float() + 1.0) / 2.0).clamp(0, 1) * 255.0
arr = samples[0].permute(1, 2, 0).cpu().numpy().astype("uint8")
# Binarize outer layer Alpha channel
arr[:, :, 3] = np.where(arr[:, :, 3] > 128, 255, 0)
skin_image = Image.fromarray(arr, mode="RGBA")
skin_image.save("generated_skin.png")