Spaces:
Running on Zero
Running on Zero
update app
Browse files
app.py
CHANGED
|
@@ -10,8 +10,9 @@ import random
|
|
| 10 |
import base64
|
| 11 |
from io import BytesIO
|
| 12 |
from PIL import Image
|
|
|
|
| 13 |
|
| 14 |
-
from diffusers import Flux2KleinPipeline
|
| 15 |
|
| 16 |
MAX_SEED = np.iinfo(np.int32).max
|
| 17 |
LANCZOS = getattr(Image, "Resampling", Image).LANCZOS
|
|
@@ -21,19 +22,12 @@ dtype = torch.bfloat16
|
|
| 21 |
|
| 22 |
print("Using device:", device)
|
| 23 |
|
| 24 |
-
print("Loading
|
| 25 |
-
vae_small = AutoencoderKLFlux2.from_pretrained(
|
| 26 |
-
"black-forest-labs/FLUX.2-small-decoder",
|
| 27 |
-
torch_dtype=dtype,
|
| 28 |
-
).to(device)
|
| 29 |
-
|
| 30 |
-
print("Loading 4B Distilled model (Small Decoder VAE)...")
|
| 31 |
pipe = Flux2KleinPipeline.from_pretrained(
|
| 32 |
-
"black-forest-labs/FLUX.2-klein-
|
| 33 |
-
vae=vae_small,
|
| 34 |
torch_dtype=dtype,
|
| 35 |
).to(device)
|
| 36 |
-
print("
|
| 37 |
|
| 38 |
def pil_to_b64_png(image: Image.Image) -> str:
|
| 39 |
buf = BytesIO()
|
|
@@ -56,7 +50,7 @@ def infer(
|
|
| 56 |
steps: int,
|
| 57 |
guidance_scale: float,
|
| 58 |
) -> dict:
|
| 59 |
-
"""Generates an image from a scribble using FLUX.2 Klein
|
| 60 |
gc.collect()
|
| 61 |
torch.cuda.empty_cache()
|
| 62 |
|
|
|
|
| 10 |
import base64
|
| 11 |
from io import BytesIO
|
| 12 |
from PIL import Image
|
| 13 |
+
from typing import Tuple
|
| 14 |
|
| 15 |
+
from diffusers import Flux2KleinPipeline
|
| 16 |
|
| 17 |
MAX_SEED = np.iinfo(np.int32).max
|
| 18 |
LANCZOS = getattr(Image, "Resampling", Image).LANCZOS
|
|
|
|
| 22 |
|
| 23 |
print("Using device:", device)
|
| 24 |
|
| 25 |
+
print("Loading FLUX.2 Klein 9B model base...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
pipe = Flux2KleinPipeline.from_pretrained(
|
| 27 |
+
"black-forest-labs/FLUX.2-klein-9B",
|
|
|
|
| 28 |
torch_dtype=dtype,
|
| 29 |
).to(device)
|
| 30 |
+
print("Base Model loaded successfully.")
|
| 31 |
|
| 32 |
def pil_to_b64_png(image: Image.Image) -> str:
|
| 33 |
buf = BytesIO()
|
|
|
|
| 50 |
steps: int,
|
| 51 |
guidance_scale: float,
|
| 52 |
) -> dict:
|
| 53 |
+
"""Generates an image from a scribble using FLUX.2 Klein 9B."""
|
| 54 |
gc.collect()
|
| 55 |
torch.cuda.empty_cache()
|
| 56 |
|