Nekochu commited on
Commit
c49a405
·
1 Parent(s): d4579d5

exact copy of working private Space: Docker + n-Arno V1 Turbo + CFG 1 (899s proven)

Browse files
Files changed (4) hide show
  1. Dockerfile +22 -0
  2. README.md +1 -3
  3. app.py +8 -43
  4. requirements.txt +0 -3
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ RUN apt-get update && apt-get install -y --no-install-recommends \
4
+ git cmake build-essential && \
5
+ rm -rf /var/lib/apt/lists/*
6
+
7
+ RUN git clone --depth 1 --recurse-submodules https://github.com/leejet/stable-diffusion.cpp /tmp/sdcpp && \
8
+ cd /tmp/sdcpp && mkdir build && cd build && \
9
+ cmake .. -DCMAKE_BUILD_TYPE=Release \
10
+ -DSD_BUILD_SHARED_LIBS=OFF && \
11
+ cmake --build . --config Release -j1 && \
12
+ cp bin/sd-cli /usr/local/bin/sd-cli && \
13
+ rm -rf /tmp/sdcpp
14
+
15
+ RUN pip install --no-cache-dir "gradio[mcp]" Pillow huggingface-hub
16
+
17
+ WORKDIR /app
18
+ COPY app.py .
19
+ COPY README.md .
20
+
21
+ EXPOSE 7860
22
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -3,9 +3,7 @@ title: Anima Base v1.0 CPU
3
  emoji: 🎨
4
  colorFrom: indigo
5
  colorTo: red
6
- sdk: gradio
7
- sdk_version: 6.14.0
8
- app_file: app.py
9
  pinned: false
10
  license: other
11
  short_description: Anime image generation with Anima Base v1.0 on CPU
 
3
  emoji: 🎨
4
  colorFrom: indigo
5
  colorTo: red
6
+ sdk: docker
 
 
7
  pinned: false
8
  license: other
9
  short_description: Anime image generation with Anima Base v1.0 on CPU
app.py CHANGED
@@ -31,47 +31,13 @@ def _ensure_file(repo_id, filename, dest_dir):
31
  return hf_hub_download(repo_id=repo_id, filename=filename, local_dir=dest_dir)
32
 
33
 
34
- BIN_DIR = os.environ.get("ANIMA_BIN_DIR", "/tmp/anima_bin")
35
- os.makedirs(BIN_DIR, exist_ok=True)
36
-
37
- SDCLI_RELEASE_URL = (
38
- "https://github.com/leejet/stable-diffusion.cpp/releases/download/"
39
- "master-615-67dda3f/sd-master-67dda3f-bin-Linux-Ubuntu-24.04-x86_64.zip"
40
- )
41
-
42
-
43
  def _ensure_sdcli():
44
- """Find sd-cli in PATH or download pre-built binary."""
45
- import zipfile, stat
46
- for candidate in [
47
- os.path.join(BIN_DIR, "sd-cli"),
48
- shutil.which("sd-cli"),
49
- shutil.which("sd-cli.exe"),
50
- ]:
51
  if candidate and os.path.isfile(candidate):
52
  return candidate
53
-
54
- if sys.platform == "win32":
55
- print("[init] sd-cli not in PATH. Build stable-diffusion.cpp from source.")
56
- sys.exit(1)
57
-
58
- print("[init] Downloading pre-built sd-cli...")
59
- zip_path = os.path.join(BIN_DIR, "sdcli.zip")
60
- subprocess.run(["curl", "-sL", "-o", zip_path, SDCLI_RELEASE_URL], check=True)
61
- with zipfile.ZipFile(zip_path) as zf:
62
- for name in zf.namelist():
63
- basename = os.path.basename(name)
64
- if basename in ("sd-cli", "libstable-diffusion.so"):
65
- dest = os.path.join(BIN_DIR, basename)
66
- with zf.open(name) as src, open(dest, "wb") as dst:
67
- shutil.copyfileobj(src, dst)
68
- os.chmod(dest, os.stat(dest).st_mode | stat.S_IEXEC)
69
- os.remove(zip_path)
70
- cli_path = os.path.join(BIN_DIR, "sd-cli")
71
- if not os.path.isfile(cli_path):
72
- raise RuntimeError("sd-cli not found in release zip")
73
- print(f"[init] sd-cli ready at {cli_path}")
74
- return cli_path
75
 
76
 
77
  SDCLI_PATH = None
@@ -146,7 +112,6 @@ def _run_sdcli(cmd, timeout=TIMEOUT):
146
  global _active_t0, _user_killed
147
  env = os.environ.copy()
148
  env.update(_CHILD_ENV_OVERRIDES)
149
- env["LD_LIBRARY_PATH"] = BIN_DIR + ":" + env.get("LD_LIBRARY_PATH", "")
150
  _trim_process_memory()
151
 
152
  # Disk-backed logs avoid growing the Gradio host RSS throughout a long verbose run.
@@ -301,7 +266,7 @@ def _init_models():
301
  print("[init] Ensuring AIO GGUF model file...")
302
  t0 = time.time()
303
  aio_path = _ensure_file(
304
- "n-Arno/Anima-P3-Turbo-AIO-Q4_K", "Anima-V1-Turbo-AIO-Q4_K.gguf",
305
  MODELS_DIR,
306
  )
307
  print(f"[init] Model ready in {time.time()-t0:.1f}s")
@@ -338,9 +303,9 @@ def main():
338
  analytics_enabled=False,
339
  ) as demo:
340
  gr.Markdown(
341
- "**[Anima V1 Turbo AIO Q4_K](https://huggingface.co/n-Arno/Anima-P3-Turbo-AIO-Q4_K)** GGUF "
342
- "([DiT anima-base-v1.0](https://huggingface.co/circlestone-labs/Anima) "
343
- "+ [DMD2 Turbo](https://civitai.red/models/2619830) + abliterated TE) "
344
  "via [sd.cpp](https://github.com/leejet/stable-diffusion.cpp) | "
345
  f"CFG {CFG}, {SAMPLER} | CPU ~15m @512x512"
346
  )
 
31
  return hf_hub_download(repo_id=repo_id, filename=filename, local_dir=dest_dir)
32
 
33
 
 
 
 
 
 
 
 
 
 
34
  def _ensure_sdcli():
35
+ """Find sd-cli in PATH (Docker provides it) or local build."""
36
+ for candidate in [shutil.which("sd-cli"), shutil.which("sd-cli.exe")]:
 
 
 
 
 
37
  if candidate and os.path.isfile(candidate):
38
  return candidate
39
+ print("[init] sd-cli not found. In Docker it's pre-installed. Locally, build stable-diffusion.cpp.")
40
+ sys.exit(1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  SDCLI_PATH = None
 
112
  global _active_t0, _user_killed
113
  env = os.environ.copy()
114
  env.update(_CHILD_ENV_OVERRIDES)
 
115
  _trim_process_memory()
116
 
117
  # Disk-backed logs avoid growing the Gradio host RSS throughout a long verbose run.
 
266
  print("[init] Ensuring AIO GGUF model file...")
267
  t0 = time.time()
268
  aio_path = _ensure_file(
269
+ "n-Arno/Anima-P3-Turbo-AIO-Q4_K", "nArnima-Turbo-SdCpp_Q4_K.gguf",
270
  MODELS_DIR,
271
  )
272
  print(f"[init] Model ready in {time.time()-t0:.1f}s")
 
303
  analytics_enabled=False,
304
  ) as demo:
305
  gr.Markdown(
306
+ "**[n-Arno Anima-V1-Turbo AIO Q4_K](https://huggingface.co/n-Arno/Anima-P3-Turbo-AIO-Q4_K)** GGUF "
307
+ "(VAE + LLM + [DiT anima-base-v1.0](https://huggingface.co/circlestone-labs/Anima) "
308
+ "+ [Turbo LoRA](https://civitai.com/models/2560840/anima-turbo-lora) merged) "
309
  "via [sd.cpp](https://github.com/leejet/stable-diffusion.cpp) | "
310
  f"CFG {CFG}, {SAMPLER} | CPU ~15m @512x512"
311
  )
requirements.txt DELETED
@@ -1,3 +0,0 @@
1
- gradio[mcp]
2
- Pillow
3
- huggingface-hub