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 PyPI

🤗 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 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.1.0.tar.gz (105.1 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.1.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for diffusers_ncsn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d880737f5bb1f76c65c99ec99ab62bb62b9eb29d148dee0d592fb9954dada23e
MD5 48a80b30a3f9136c1d75fe228bc0057b
BLAKE2b-256 d441af25b419957f05caef290a33b8f13f2c88eeaf86b496b2a111bf6fe530c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for diffusers_ncsn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f119e544ba04fcdd16cdca1547cb28ad7b3a01fdf4530b0655ae46cebb6f843a
MD5 04b4ecbcf90e36e0a56902ab119426db
BLAKE2b-256 d5d777c683b5918c7e80cf849447028ae112c711321489b3aa3af6d5047dd77a

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