Downloads · 30 days
29
19% of all-time downloads
rijulpaul/ddpm-ffhq-128
ddpm-ffhq-128 is a machine learning model from rijulpaul. 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.
<img src="https://github.com/rijulpaul/ddpm-ffhq-128/blob/main/results.png?raw=true" /
Downloads · 30 days
29
19% of all-time downloads
All-time downloads
150
Public
Parameters
112M
2.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.pt1.8 GB · 67%
From the Hugging Face model README
Useful Links:
<a href="https://huggingface.co/spaces/rijulpaul/ddpm-ffhq-128" target="_blank">
<img alt="Hugging Face Space" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Space-ffc107?color=ffc107&logoColor=white" />
</a>
<a href="https://huggingface.co/rijulpaul/ddpm-ffhq-128" target="_blank">
<img alt="Hugging Face Space" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Model-ffc107?color=ffc107&logoColor=white" />
</a>
<a href="https://github.com/rijulpaul/ddpm-ffhq-128" target="_blank">
<img alt="Hugging Face" src="https://img.shields.io/badge/Github-Repo-black?logo=github" />
</a>
<a href="https://www.kaggle.com/code/rijulpaul/diffusion-model-on-ffhq" target="_blank">
<img alt="Kaggle Notebook" src="https://img.shields.io/badge/Kaggle-Notebook-blue?logo=kaggle" />
</a>
<a href="https://www.kaggle.com/datasets/arnaud58/flickrfaceshq-dataset-ffhq" target="_blank">
<img alt="Kaggle Dataset" src="https://img.shields.io/badge/Kaggle-Dataset-blue?logo=kaggle" />
</a>
This project uses a DDPM based Diffusion techinique to learn to generate human faces from noise. The dataset used is flickr-faces-ffhq
# pipeline.py
from diffusers import DiffusionPipeline
import torch
from PIL import Image
class Pipeline:
def __init__(self):
self.device = "cuda" if torch.cuda.is_available() else "cpu"
model_id = "rijulpaul/ddpm-ffhq-128"
self.pipe = DiffusionPipeline.from_pretrained(
model_id,
).to(self.device)
def generate(self, seed=None, num_inference_steps=20):
generator = None
if seed is not None and seed != -1:
generator = torch.Generator(device=self.device).manual_seed(int(seed))
image = self.pipe(
num_inference_steps=num_inference_steps,
generator=generator
).images[0]
return image
pipe = Pipeline()
def generate_image(seed, steps):
if seed == -1:
seed = random.randint(0, 1_000_000)
img = pipe.generate(seed=seed, num_inference_steps=steps)
if not isinstance(img, Image.Image):
img = Image.fromarray(img)
path = "output.png"
img.save(path)
seed = 182341
steps = 1000
generate_image(seed,steps)