File size: 811 Bytes
4068184
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from dotenv import load_dotenv
import os
import torch
from diffusers import FluxPipeline

# Load the environment variables from .env
load_dotenv()

# Access the token
access_token = os.getenv("HUGGING_FACE_HUB_TOKEN")

# Load the pipeline
pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.1-dev",
    torch_dtype=torch.bfloat16
)

# Move the pipeline to the CPU
pipe.to("cpu")

# Define the prompt
prompt = "A homeless cat holding a sign which says, 'Will Youtube for Food'"

# Generate the image using the pipeline
image = pipe(
    prompt,
    height=1024,
    width=1024,
    guidance_scale=3.5,
    num_inference_steps=50,
    max_sequence_length=512,
    generator=torch.Generator("cpu").manual_seed(0)  # Use CPU generator
).images[0]

# Save the generated image
image.save("fluxpng.dev")