Coder Social home page Coder Social logo

dim's Introduction

Install

Install Mamba-ssm

Refer to Vision Mamba

# Install causal_conv1d and mamba
pip install -e causal_conv1d>=1.1.0
pip install -e mamba-1p1p1

Train

# Assign HF_HOME to the cache directory
export HF_HOME="/comp_robot/rentianhe/caohe/cache"

# Train with 4 GPUs
accelerate launch --multi_gpu --num_processes 4 --mixed_precision fp16 train_mamba.py --model DiM-S/2 --feature-path /shared_space/caohe/DATA/imagenet1k/train_vae --lr 5e-4
  • feature-path: the path to the pre-extracted features (use SD-VAE compression rate as 8)
  • model: the model name (Now supported DiM-[S|M|L|XL]/[2|4|8])
  • [default] batch size : global batch size = 256 (constant for all models, suggested in DiT)
  • [optional] --lr : learning rate (default 1e-4, for mamba, 5e-4 is suggested)
  • [optional] --ckpt-every: default to 50_000 (= 10 epochs)

The ckpt will be saved under results/xxx-MODEL_VERSION/checkpoints/

Evaluation

Sampling scripts

# Assign HF_HOME to the cache directory
export HF_HOME="/comp_robot/rentianhe/caohe/cache"
# 
MODEL_VERSION=005-DiM-S-2 # The model version
CKPT=0100000 # The checkpoint number
torchrun --nnodes=1 --nproc_per_node=4 sample_ddp.py --model DiM-S/2 --num-fid-samples 50000 --ckpt results/$MODEL_VERSION/checkpoints/$CKPT.pt --sample-dir samples/$MODEL_VERSION-$CKPT --per-proc-batch-size 64

FID evaluation

First need to install related packages following ADM's TensorFlow evaluation suite

IN_50K_REFERENCE=/shared_space/caohe/DATA/imagenet1k/VIRTUAL_imagenet256_labeled.npz
# ! adapt the path to the sample features path
python evaluations/evaluator.py $IN_50K_REFERENCE samples/DiM-B-2-ckpt-0100000/DiM-B-2-0100000-size-256-vae-ema-cfg-1.5-seed-0.npz

dim's People

Contributors

wpeebles avatar rentainhe avatar ciaohe avatar eltociear avatar s9xie avatar

Stargazers

Zhuzhu Wei avatar  avatar Xuantong LIU avatar Ling-Hao CHEN avatar

Forkers

jinzhuwei

dim's Issues

about Image sampling

Thanks for the Mamba based diffusion model code. Has your team successfully used this code to generate images? Thank you again for your selfless sharing and I look forward to your reply. Wish you the best at work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.