Initial Seg Data Server Net platform
This commit is contained in:
13
scripts/init_git_lfs.sh
Executable file
13
scripts/init_git_lfs.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if ! command -v git-lfs >/dev/null 2>&1 && ! git lfs version >/dev/null 2>&1; then
|
||||
echo "git-lfs is not installed on this host." >&2
|
||||
echo "Install git-lfs or publish weights through Gitea releases/packages." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git lfs install
|
||||
git lfs track "*.pt" "*.pth" "*.onnx" "*.engine"
|
||||
git add .gitattributes
|
||||
|
||||
11
scripts/run_backend.sh
Executable file
11
scripts/run_backend.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BACKEND_ENV="${SEG_BACKEND_CONDA_ENV:-seg_server}"
|
||||
HOST="${SEG_BACKEND_HOST:-0.0.0.0}"
|
||||
PORT="${SEG_BACKEND_PORT:-8000}"
|
||||
|
||||
cd "${ROOT_DIR}"
|
||||
exec conda run -n "${BACKEND_ENV}" uvicorn app.main:app --app-dir backend --host "${HOST}" --port "${PORT}" --reload
|
||||
|
||||
8
scripts/run_frontend.sh
Executable file
8
scripts/run_frontend.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "${ROOT_DIR}/frontend"
|
||||
npm install
|
||||
exec npm run dev -- --host 0.0.0.0
|
||||
|
||||
33
scripts/sync_weights.py
Executable file
33
scripts/sync_weights.py
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
BACKEND = ROOT / "backend"
|
||||
sys.path.insert(0, str(BACKEND))
|
||||
|
||||
from app.modules.weights.service import sync_weights # noqa: E402
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Sync Seg weight files into Seg_Data_Server_Net/weights.")
|
||||
parser.add_argument("--mode", choices=["copy", "reflink", "hardlink"], default="copy")
|
||||
parser.add_argument("--hash", action="store_true", help="calculate sha256 for every copied weight")
|
||||
parser.add_argument("--no-skip-existing", action="store_true", help="recopy files even when size matches")
|
||||
args = parser.parse_args()
|
||||
manifest = sync_weights(
|
||||
mode=args.mode,
|
||||
hash_files=args.hash,
|
||||
skip_existing=not args.no_skip_existing,
|
||||
)
|
||||
total_gb = manifest["total_bytes"] / 1024 / 1024 / 1024
|
||||
print(f"synced {manifest['count']} weights, total {total_gb:.2f} GB")
|
||||
print("manifest:", ROOT / "weights" / "manifest.json")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user