Spaces:
Runtime error
Runtime error
Abhishek commited on
Commit ·
fb564cb
1
Parent(s): 5394bd3
Migrate from FLUX.1-schnell to FLUX.2-klein-base-4B
Browse files- Dockerfile +2 -2
- configs/model_registry.yaml +1 -1
- configs/sponsor_model_policy.yaml +1 -1
- requirements.txt +1 -1
- run_local.sh +1 -1
- src/apps/p5_memory_quilt/flux_backend.py +6 -4
- tests/test_sponsor_model_policy.py +1 -1
Dockerfile
CHANGED
|
@@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive \
|
|
| 5 |
PORT=7860 \
|
| 6 |
HOST=0.0.0.0 \
|
| 7 |
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 8 |
-
P5_FLUX_MODEL_DIR=/app/models/FLUX.
|
| 9 |
|
| 10 |
RUN apt-get update \
|
| 11 |
&& apt-get install -y --no-install-recommends git ca-certificates libcurl4 libgomp1 libstdc++6 \
|
|
@@ -28,7 +28,7 @@ ENV HF_TOKEN=${HF_TOKEN}
|
|
| 28 |
RUN pip install huggingface_hub hf_transfer
|
| 29 |
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=false \
|
| 30 |
if [ -f /run/secrets/HF_TOKEN ]; then export HF_TOKEN=$(cat /run/secrets/HF_TOKEN); fi && \
|
| 31 |
-
python scripts/download_model.py black-forest-labs/FLUX.
|
| 32 |
python scripts/download_model.py openbmb/MiniCPM5-1B models/MiniCPM5-1B
|
| 33 |
|
| 34 |
EXPOSE 7860
|
|
|
|
| 5 |
PORT=7860 \
|
| 6 |
HOST=0.0.0.0 \
|
| 7 |
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 8 |
+
P5_FLUX_MODEL_DIR=/app/models/FLUX.2-klein-base-4B
|
| 9 |
|
| 10 |
RUN apt-get update \
|
| 11 |
&& apt-get install -y --no-install-recommends git ca-certificates libcurl4 libgomp1 libstdc++6 \
|
|
|
|
| 28 |
RUN pip install huggingface_hub hf_transfer
|
| 29 |
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=false \
|
| 30 |
if [ -f /run/secrets/HF_TOKEN ]; then export HF_TOKEN=$(cat /run/secrets/HF_TOKEN); fi && \
|
| 31 |
+
python scripts/download_model.py black-forest-labs/FLUX.2-klein-base-4B models/FLUX.2-klein-base-4B && \
|
| 32 |
python scripts/download_model.py openbmb/MiniCPM5-1B models/MiniCPM5-1B
|
| 33 |
|
| 34 |
EXPOSE 7860
|
configs/model_registry.yaml
CHANGED
|
@@ -17,7 +17,7 @@ projects:
|
|
| 17 |
p5:
|
| 18 |
image_gen:
|
| 19 |
component: image_gen
|
| 20 |
-
model_id: black-forest-labs/FLUX.
|
| 21 |
license: Apache-2.0
|
| 22 |
usage_notes: Primary tile renderer for quilt art; runtime now fails clearly if no local checkpoint is mounted.
|
| 23 |
runtime: heuristic+hf
|
|
|
|
| 17 |
p5:
|
| 18 |
image_gen:
|
| 19 |
component: image_gen
|
| 20 |
+
model_id: black-forest-labs/FLUX.2-klein-base-4B
|
| 21 |
license: Apache-2.0
|
| 22 |
usage_notes: Primary tile renderer for quilt art; runtime now fails clearly if no local checkpoint is mounted.
|
| 23 |
runtime: heuristic+hf
|
configs/sponsor_model_policy.yaml
CHANGED
|
@@ -12,4 +12,4 @@ required_models:
|
|
| 12 |
p5:
|
| 13 |
image_gen:
|
| 14 |
component: image_gen
|
| 15 |
-
model_id: black-forest-labs/FLUX.
|
|
|
|
| 12 |
p5:
|
| 13 |
image_gen:
|
| 14 |
component: image_gen
|
| 15 |
+
model_id: black-forest-labs/FLUX.2-klein-base-4B
|
requirements.txt
CHANGED
|
@@ -4,7 +4,7 @@ gradio>=5.0,<6
|
|
| 4 |
Pillow>=10.4,<11
|
| 5 |
PyYAML>=6.0,<7
|
| 6 |
torch
|
| 7 |
-
diffusers>=0.
|
| 8 |
transformers>=4.43.0
|
| 9 |
accelerate>=0.31.0
|
| 10 |
sentencepiece
|
|
|
|
| 4 |
Pillow>=10.4,<11
|
| 5 |
PyYAML>=6.0,<7
|
| 6 |
torch
|
| 7 |
+
diffusers>=0.31.0
|
| 8 |
transformers>=4.43.0
|
| 9 |
accelerate>=0.31.0
|
| 10 |
sentencepiece
|
run_local.sh
CHANGED
|
@@ -5,7 +5,7 @@ cd "$ROOT"
|
|
| 5 |
|
| 6 |
export P5_MEMORY_QUILT_FALLBACK_MODEL_PATH=$(ls -d /root/docker-data/hf_cache/hub/models--openbmb--MiniCPM5-1B/snapshots/* | head -n 1)
|
| 7 |
export P5_MEMORY_QUILT_PRIMARY_MODEL_PATH=$(ls -d /root/docker-data/hf_cache/hub/models--JetBrains--Mellum2-12B-A2.5B-Instruct/snapshots/* 2>/dev/null | head -n 1 || echo "$P5_MEMORY_QUILT_FALLBACK_MODEL_PATH")
|
| 8 |
-
export P5_FLUX_MODEL_DIR=$(ls -d /root/docker-data/hf_cache/hub/models--black-forest-labs--FLUX.
|
| 9 |
|
| 10 |
if [ ! -d "/tmp/p5_venv" ]; then
|
| 11 |
python3 -m venv /tmp/p5_venv
|
|
|
|
| 5 |
|
| 6 |
export P5_MEMORY_QUILT_FALLBACK_MODEL_PATH=$(ls -d /root/docker-data/hf_cache/hub/models--openbmb--MiniCPM5-1B/snapshots/* | head -n 1)
|
| 7 |
export P5_MEMORY_QUILT_PRIMARY_MODEL_PATH=$(ls -d /root/docker-data/hf_cache/hub/models--JetBrains--Mellum2-12B-A2.5B-Instruct/snapshots/* 2>/dev/null | head -n 1 || echo "$P5_MEMORY_QUILT_FALLBACK_MODEL_PATH")
|
| 8 |
+
export P5_FLUX_MODEL_DIR=$(ls -d /root/docker-data/hf_cache/hub/models--black-forest-labs--FLUX.2-klein-base-4B/snapshots/* | head -n 1)
|
| 9 |
|
| 10 |
if [ ! -d "/tmp/p5_venv" ]; then
|
| 11 |
python3 -m venv /tmp/p5_venv
|
src/apps/p5_memory_quilt/flux_backend.py
CHANGED
|
@@ -16,7 +16,7 @@ import time
|
|
| 16 |
|
| 17 |
@dataclass(frozen=True)
|
| 18 |
class FluxConfig:
|
| 19 |
-
model_id: str = "black-forest-labs/FLUX.
|
| 20 |
model_dir: str = ""
|
| 21 |
steps: int = 4
|
| 22 |
guidance_scale: float | None = None
|
|
@@ -26,7 +26,7 @@ class FluxConfig:
|
|
| 26 |
|
| 27 |
|
| 28 |
def _load_config(size: int = 512) -> FluxConfig:
|
| 29 |
-
model_id = os.environ.get("P5_FLUX_MODEL_ID", "black-forest-labs/FLUX.
|
| 30 |
model_dir = os.environ.get("P5_FLUX_MODEL_DIR", "").strip()
|
| 31 |
steps = int(os.environ.get("P5_FLUX_STEPS", "4"))
|
| 32 |
guidance_raw = os.environ.get("P5_FLUX_GUIDANCE", "").strip()
|
|
@@ -78,8 +78,10 @@ def try_generate(prompt: str, size: int = 512):
|
|
| 78 |
|
| 79 |
model_ref: str = cfg.model_dir
|
| 80 |
|
| 81 |
-
# Prefer the explicit
|
| 82 |
-
PipelineCls = getattr(diffusers, "
|
|
|
|
|
|
|
| 83 |
if PipelineCls is None:
|
| 84 |
from diffusers import DiffusionPipeline as PipelineCls # type: ignore
|
| 85 |
|
|
|
|
| 16 |
|
| 17 |
@dataclass(frozen=True)
|
| 18 |
class FluxConfig:
|
| 19 |
+
model_id: str = "black-forest-labs/FLUX.2-klein-base-4B"
|
| 20 |
model_dir: str = ""
|
| 21 |
steps: int = 4
|
| 22 |
guidance_scale: float | None = None
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def _load_config(size: int = 512) -> FluxConfig:
|
| 29 |
+
model_id = os.environ.get("P5_FLUX_MODEL_ID", "black-forest-labs/FLUX.2-klein-base-4B").strip()
|
| 30 |
model_dir = os.environ.get("P5_FLUX_MODEL_DIR", "").strip()
|
| 31 |
steps = int(os.environ.get("P5_FLUX_STEPS", "4"))
|
| 32 |
guidance_raw = os.environ.get("P5_FLUX_GUIDANCE", "").strip()
|
|
|
|
| 78 |
|
| 79 |
model_ref: str = cfg.model_dir
|
| 80 |
|
| 81 |
+
# Prefer the explicit Flux2KleinPipeline if present; otherwise fall back to FluxPipeline or DiffusionPipeline.
|
| 82 |
+
PipelineCls = getattr(diffusers, "Flux2KleinPipeline", None)
|
| 83 |
+
if PipelineCls is None:
|
| 84 |
+
PipelineCls = getattr(diffusers, "FluxPipeline", None)
|
| 85 |
if PipelineCls is None:
|
| 86 |
from diffusers import DiffusionPipeline as PipelineCls # type: ignore
|
| 87 |
|
tests/test_sponsor_model_policy.py
CHANGED
|
@@ -33,7 +33,7 @@ def test_sponsor_model_checker_fails_without_waiver_for_mismatch(tmp_path: Path)
|
|
| 33 |
completed = run_checker("--model-registry", str(mismatch_path), "--policy", str(POLICY))
|
| 34 |
assert completed.returncode == 1
|
| 35 |
assert "sponsor model mismatch" in completed.stderr.lower()
|
| 36 |
-
assert "black-forest-labs/FLUX.
|
| 37 |
|
| 38 |
|
| 39 |
def test_sponsor_model_checker_passes_with_valid_waiver_and_warns(tmp_path: Path) -> None:
|
|
|
|
| 33 |
completed = run_checker("--model-registry", str(mismatch_path), "--policy", str(POLICY))
|
| 34 |
assert completed.returncode == 1
|
| 35 |
assert "sponsor model mismatch" in completed.stderr.lower()
|
| 36 |
+
assert "black-forest-labs/FLUX.2-klein-base-4B" in completed.stderr
|
| 37 |
|
| 38 |
|
| 39 |
def test_sponsor_model_checker_passes_with_valid_waiver_and_warns(tmp_path: Path) -> None:
|