Skip to main content

Diffusers implementation of Noise Conditional Score Networks (NCSN) [Yang+ NeuriPS'19]

Project description

🤗 Noise Conditional Score Networks

CI Document ermongroup/ncsn Model on HF

🤗 diffusers implementation of the paper "Generative Modeling by Estimating Gradients of the Data Distribution" [Yang+ NeurIPS'19].

How to use

Use without installation

You can load the pretrained pipeline directly from the HF Hub as follows:

import torch
from diffusers import DiffusionPipeline
from diffusers.utils import make_image_grid

# Specify the device to use
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

#
# Load the pipeline from the Hugging Face Hub
#
pipe = DiffusionPipeline.from_pretrained(
    "py-img-gen/ncsn-mnist", trust_remote_code=True
)
pipe = pipe.to(device)

# Generate samples; here, we specify the seed and generate 16 images
output = pipe(
    batch_size=16,
    generator=torch.manual_seed(42),
)

# Create a grid image from the generated samples
image = make_image_grid(images=output.images, rows=4, cols=4)
image.save("output.png")

Use with installation

First, install the package from this repository:

pip install git+https://github.com/py-img-gen/diffusers-ncsn

Then, you can use the package as follows:

import torch

from ncsn.pipeline_ncsn import NCSNPipeline

# Specify the device to use
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

#
# Load the pipeline from the HF Hub through the NCSNPipeline of this library
#
pipe = NCSNPipeline.from_pretrained("py-img-gen/ncsn-mnist", trust_remote_code=True)
pipe = pipe.to(device)

# Generate samples; here, we specify the seed and generate 16 images
output = pipe(
    batch_size=16,
    generator=torch.manual_seed(42),
)

# Create a grid image from the generated samples
image = make_image_grid(images=output.images, rows=4, cols=4)
image.save("output.png")

Pretrained models and pipeline

Model on HF

Showcase

MNIST

Example of generating MNIST character images using the model trained with train_mnist.py.

mnist

Notes on uploading pipelines to the HF Hub with custom components

While referring to 📝 Load community pipelines and components - huggingface diffusers, pay attention to the following points.

License

diffusers-ncsn is licensed under Apache 2.0. A full copy of the license can be found on GitHub.

Acknowledgements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffusers_ncsn-0.0.1.tar.gz (103.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffusers_ncsn-0.0.1-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file diffusers_ncsn-0.0.1.tar.gz.

File metadata

  • Download URL: diffusers_ncsn-0.0.1.tar.gz
  • Upload date:
  • Size: 103.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.26

File hashes

Hashes for diffusers_ncsn-0.0.1.tar.gz
Algorithm Hash digest
SHA256 0a75a7cfb812265251f38d5d5705f3198c70344987885a19407b42564b6ffce0
MD5 b30f8019ca80c3f6c67c9ba2a1f341a0
BLAKE2b-256 0f2244ba15194a1f8111b2f7096b7918fd97f44d36da0d015be21a91cc5333e9

See more details on using hashes here.

File details

Details for the file diffusers_ncsn-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for diffusers_ncsn-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ccc15a30543171762ee4c69bbc01f5792539da5e96873a65db9b3ef0365182c1
MD5 861f9f177200e10a69ff56ce2f903212
BLAKE2b-256 33266b76f69d5bb69e96cfef0712ef07d48bdb99c68f9fd90854698580fcecd2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page