Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,13 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from diffusers import
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
|
| 6 |
-
# Load the
|
| 7 |
@st.cache_resource
|
| 8 |
def load_pipeline():
|
| 9 |
# Using the 'black-forest-labs/FLUX.1-schnell' model
|
| 10 |
-
pipe =
|
| 11 |
pipe.enable_model_cpu_offload() # Offload to CPU to save memory
|
| 12 |
return pipe
|
| 13 |
|
|
@@ -28,8 +28,6 @@ if st.button("Generate Image"):
|
|
| 28 |
user_prompt,
|
| 29 |
guidance_scale=0.0, # No guidance
|
| 30 |
num_inference_steps=4, # Number of steps for faster generation
|
| 31 |
-
max_sequence_length=256,
|
| 32 |
-
generator=torch.Generator("cpu").manual_seed(0) # Ensure reproducibility
|
| 33 |
).images[0]
|
| 34 |
|
| 35 |
# Save and display the image
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from diffusers import DiffusionPipeline
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
|
| 6 |
+
# Load the FLUX model
|
| 7 |
@st.cache_resource
|
| 8 |
def load_pipeline():
|
| 9 |
# Using the 'black-forest-labs/FLUX.1-schnell' model
|
| 10 |
+
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
|
| 11 |
pipe.enable_model_cpu_offload() # Offload to CPU to save memory
|
| 12 |
return pipe
|
| 13 |
|
|
|
|
| 28 |
user_prompt,
|
| 29 |
guidance_scale=0.0, # No guidance
|
| 30 |
num_inference_steps=4, # Number of steps for faster generation
|
|
|
|
|
|
|
| 31 |
).images[0]
|
| 32 |
|
| 33 |
# Save and display the image
|