-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinference_flux.py
More file actions
47 lines (38 loc) · 1.45 KB
/
Copy pathinference_flux.py
File metadata and controls
47 lines (38 loc) · 1.45 KB
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
39
40
41
42
43
44
45
46
47
import os
from pipelines.pipeline_flux import FluxMultiDiffusionPipeline
import diffusers
import torch
from diffusers.utils import load_image
from PIL import Image
Image.MAX_IMAGE_PIXELS = None
import numpy as np
import cv2
from pathlib import Path
base_model = "black-forest-labs/FLUX.1-dev"
inference_dtype = torch.bfloat16
base = FluxMultiDiffusionPipeline.from_pretrained(
base_model,
torch_dtype=inference_dtype,
)
base.enable_model_cpu_offload(0)
instanceprompt = ("A breathtaking, ultra-wide panoramic landscape of jagged obsidian mountain peaks at twilight. The valleys are filled with flowing rivers of glowing violet bioluminescent mist. Above, a sprawling cosmic sky features a massive, detailed nebula in shades of deep teal and gold, with scattered crystalline stars. Photorealistic, cinematic lighting, 8k resolution, highly detailed rock textures, atmospheric depth, ethereal glow, wide-angle lens.")
#Path + name
output_path = Path("./outputs")
output_path.mkdir(parents=True, exist_ok=True)
img_name = "res_flux1"
TARGET_HEIGHT = 2048
TARGET_WIDTH = 2048
image = base(
prompt = instanceprompt,
height = 1024,
width = 1024,
total_height = TARGET_HEIGHT,
total_width = TARGET_WIDTH,
num_inference_steps = 28,
guidance_scale = 4.0, #helps FLUX.1-dev follow the prompt
view_batch_size = 1,
stride_start= 512,
stride_end= 512 + 256,
return_dict = False
)[0][0]
image.save(output_path / f"{img_name}.png")