Downloads · 30 days
5
1% of all-time downloads
gnokit/unet-mnist-32
unet-mnist-32 is a machine learning model from gnokit. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for diffusers. The card lists the license as apache-2.0.
Downloads · 30 days
5
1% of all-time downloads
All-time downloads
740
Public
Repo size
191 MB
Likes
0
Public
Click a slice to open those files.
.safetensors63.6 MB · 100%
From the Hugging Face model README

The model is a generative model specifically designed for digit image generation. It is trained on the MNIST dataset, which consists of handwritten digit images. The model is capable of generating realistic black and white digit images of numbers 0 to 9 with a size of 32x32 pixels.
from diffusers import UNet2DModel
unet = UNet2DModel(
in_channels=1,
out_channels=1,
sample_size=32,
block_out_channels=(32,64,128,256),
norm_num_groups=8,
num_class_embeds=10
)
Example Python code snippets and instructions for using the model to generate image.
from diffusers import UNet2DModel, DDPMScheduler
device = "cuda"
scheduler = DDPMScheduler()
unet = UNet2DModel.from_pretrained("gnokit/unet-mnist-32", use_safetensors=True, variant="fp16").to(device)
class_to_generate = 8 # 0-9
sample = torch.randn(1, 1, 32, 32).to(device)
class_labels = [class_to_generate]
class_labels = torch.tensor(class_labels).to(device)
for i, t in enumerate(scheduler.timesteps):
# Get model pred
with torch.no_grad():
noise_pred = unet(sample, t, class_labels=class_labels).sample
# Update sample with step
sample = scheduler.step(noise_pred, t, sample).prev_sample
image = sample.clip(-1, 1)*0.5 + 0.5 # image in tensor format
license: apache-2.0 datasets: