Instructions to use Dinghuai/flow-matching-cifar10 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use Dinghuai/flow-matching-cifar10 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Dinghuai/flow-matching-cifar10", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Use the following code:
from diffusers.models.unets import UNet2DModel
from diffusers.models.embeddings import GaussianFourierProjection
class MyUNet2DModel(UNet2DModel):
def __init__(self, *args, **kwargs):
block_out_channels = (128, 256, 256, 256)
super(MyUNet2DModel, self).__init__(
in_channels=3, out_channels=3,
time_embedding_type="fourier",
down_block_types=("DownBlock2D", "AttnDownBlock2D", "AttnDownBlock2D", "AttnDownBlock2D"),
up_block_types=("AttnUpBlock2D", "AttnUpBlock2D", "AttnUpBlock2D", "UpBlock2D"),
act_fn="silu",
block_out_channels=block_out_channels,
layers_per_block=2,
norm_num_groups=32,
norm_eps=1e-6,
)
self.time_proj = GaussianFourierProjection(embedding_size=block_out_channels[0], scale=16,
set_W_to_weight=False, log=False) # default log=True
# this cause inf https://github.com/huggingface/diffusers/blob/a536e775fb95daf57abf02dc401e02701591bf69/src/diffusers/models/unets/unet_2d.py#L341
self.config.time_embedding_type = "my_fourier" # use a weird name to avoid inf
model = MyUNet2DModel()
model.from_pretrained("Dinghuai/flow-matching-cifar10")
- Downloads last month
- 108
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support