Views
No views yet
1# Basic usage example
2from diffusers import DiffusionPipeline
3import torch
4
5# Load the model (with float16 precision for GPU)
6pipe = DiffusionPipeline.from_pretrained(
7 "Heartsync/NSFW-Uncensored",
8 torch_dtype=torch.float16
9)
10pipe.to("cuda") # Move to GPU
11
12# Generate an image with a simple prompt
13prompt = "Woman in an elegant dress standing by a window, detailed lighting, 8k"
14negative_prompt = "low quality, blurry, deformed"
15
16# Create the image
17image = pipe(
18 prompt=prompt,
19 negative_prompt=negative_prompt,
20 num_inference_steps=30,
21 guidance_scale=7.5
22).images[0]
23
24# Save the image
25image.save("generated_image.png")
26
27# Advanced example - fixed seed and additional parameters
28import numpy as np
29
30# Set seed for reproducible results
31seed = 42
32generator = torch.Generator("cuda").manual_seed(seed)
33
34# Advanced parameter settings
35prompt = "A dramatic scene with explicit details, cinematic lighting, high resolution"
36image = pipe(
37 prompt=prompt,
38 negative_prompt="ugly, deformed, disfigured, poor quality, low resolution",
39 num_inference_steps=50, # More steps for higher quality
40 guidance_scale=8.0, # Increase prompt fidelity
41 width=768, # Adjust image width
42 height=768, # Adjust image height
43 generator=generator # Fixed seed
44).images[0]
45
46image.save("high_quality_image.png")