Untitled

 avatar
unknown
plain_text
10 months ago
930 B
10
Indexable
import random
import time
from diffusers import StableDiffusionPipeline
import torch

# Load the image generator (you need to install diffusers + torch first)
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe = pipe.to("cuda" if torch.cuda.is_available() else "cpu")

funny_subjects = [
    "a cat wearing sunglasses",
    "a penguin on a skateboard",
    "a dog playing chess",
    "a llama with a top hat",
    "an astronaut eating pizza",
]

funny_styles = [
    "cartoon style",
    "pixel art",
    "oil painting",
    "3D render",
    "children's book illustration",
]

while True:
    subject = random.choice(funny_subjects)
    style = random.choice(funny_styles)
    prompt = f"{subject}, {style}, very silly and funny"

    print(f"Generating: {prompt}")
    image = pipe(prompt).images[0]
    image.show()  # opens the image
    time.sleep(2)  # wait 2 seconds before making another
Editor is loading...
Leave a Comment