Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,6 +17,45 @@ from diffusers import FluxPipeline
|
|
17 |
|
18 |
torch.backends.cuda.matmul.allow_tf32 = True
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
class timer:
|
21 |
def __init__(self, method_name="timed process"):
|
22 |
self.method = method_name
|
|
|
17 |
|
18 |
torch.backends.cuda.matmul.allow_tf32 = True
|
19 |
|
20 |
+
|
21 |
+
|
22 |
+
base_model_id = "Freepik/flux.1-lite-8B-alpha"
|
23 |
+
torch_dtype = torch.bfloat16
|
24 |
+
device = "cpu"
|
25 |
+
|
26 |
+
# Load the pipe
|
27 |
+
model_id = "Freepik/flux.1-lite-8B-alpha"
|
28 |
+
pipe = FluxPipeline.from_pretrained(
|
29 |
+
model_id, torch_dtype=torch_dtype
|
30 |
+
).to(device)
|
31 |
+
|
32 |
+
# Inference
|
33 |
+
prompt = "A close-up image of a green alien with fluorescent skin in the middle of a dark purple forest"
|
34 |
+
|
35 |
+
guidance_scale = 3.5 # Keep guidance_scale at 3.5
|
36 |
+
n_steps = 28
|
37 |
+
seed = 11
|
38 |
+
|
39 |
+
with torch.inference_mode():
|
40 |
+
image = pipe(
|
41 |
+
prompt=prompt,
|
42 |
+
generator=torch.Generator(device="cpu").manual_seed(seed),
|
43 |
+
num_inference_steps=n_steps,
|
44 |
+
guidance_scale=guidance_scale,
|
45 |
+
height=1024,
|
46 |
+
width=1024,
|
47 |
+
).images[0]
|
48 |
+
image.save("output.png")
|
49 |
+
|
50 |
+
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
class timer:
|
60 |
def __init__(self, method_name="timed process"):
|
61 |
self.method = method_name
|