Instructions to use rijulpaul/ddpm-ffhq-128 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use rijulpaul/ddpm-ffhq-128 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("rijulpaul/ddpm-ffhq-128", 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
Diffusion Model for Human Face Generation (128x128)
Overview
This project uses a DDPM based Diffusion techinique to learn to generate human faces from noise. The dataset used is flickr-faces-ffhq
Running the Model
# 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)
- Downloads last month
- 22
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐ Ask for provider support