Text-to-Image / app.py
nagasurendra's picture
Update app.py
89042fa verified
raw
history blame contribute delete
905 Bytes
from diffusers import StableDiffusionPipeline
import torch
from PIL import Image
# Check if CUDA is available
device = "cuda" if torch.cuda.is_available() else "cpu"
# Load the pre-trained Stable Diffusion 3.5 model
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-3.5-large-turbo")
pipe.to(device)
# If you have LoRA weights, load them (replace with your actual LoRA weight path)
pipe.load_lora_weights("prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA")
# Text prompt for image generation
prompt = "Turbo Realism, High-resolution photograph, woman, UHD, photorealistic, shot on a Sony A7III --chaos 20 --ar 1:2 --style raw --stylize 250"
# Generate the image
with torch.no_grad(): # Disable gradient calculations for inference
image = pipe(prompt).images[0]
# Show the generated image
image.show()
# Optionally, save the image to disk
image.save("generated_image.png")