motif64

m64_c2cef7905f1b / start.sh

40 lines, 1.6 KBraw
1#!/usr/bin/env bash2# qwen-image-2.1-uncensored-omni-gb10 entrypoint. Runs inside the container; takes no arguments.3# Runs qwen_image_21_omni_server.py (written for this capsule, from tools/image/servers/) on pinned weights4# mounted read-only at /weights/qwen-image-2.1. 5set -eu67export HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=18export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True9export MODEL_DIR="/weights/qwen-image-2.1"10export SERVED_MODEL_ID="qwen-image-2.1-uncensored-omni"11export QWEN_IMAGE_21_TRANSFORMER="/weights/omni/qwen-image-2.1-step90000-BF16"12export QWEN_IMAGE_21_LOAD_MODE="device"13export QWEN_IMAGE_21_VAE_TILING="0"14export QWEN_IMAGE_21_STEPS="35"15export QWEN_IMAGE_21_RESOLUTION="1024"16export QWEN_IMAGE_21_TRUE_CFG="5.0"17export QWEN_IMAGE_21_NEGATIVE=" "18export PORT="$M64_PORT"1920echo '{"phase":"loading","detail":"loading Qwen-Image-2.1 Uncensored Omni"}' >> "$M64_STATUS"21# The server loads its model before it listens (or answers /health with "loading"):22# report ready once /health says "ok".23python3 - <<'PY' &24import json, os, time, urllib.request25t0 = time.time()26url = "http://127.0.0.1:%s/health" % os.environ["M64_PORT"]27opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))28while True:29    try:30        r = opener.open(url, timeout=3)31        if r.status == 200 and json.loads(r.read() or b"{}").get("status", "ok") == "ok":32            break33    except Exception:34        pass35    time.sleep(5)36with open(os.environ["M64_STATUS"], "a") as f:37    f.write(json.dumps({"phase": "ready", "detail": "loaded in %d s" % (time.time() - t0)}) + "\n")38PY3940exec python3 -u /capsule/qwen_image_21_omni_server.py