jk commited on
Commit
d53009b
Β·
1 Parent(s): 9c0879b

Initial Space: Docker layout cloning FMODetect-v2 main

Browse files
Files changed (3) hide show
  1. Dockerfile +53 -0
  2. README.md +37 -4
  3. requirements.txt +15 -0
Dockerfile ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Hugging Face Space Dockerfile for FMODetect v2.
2
+ # Builds the Next.js UI as a static export, then runs FastAPI on port 7860.
3
+ # The source repo is cloned at build time so the Space stays tiny.
4
+
5
+ ARG REPO_URL=https://github.com/jai-krishna-0921/FMODetect-v2.git
6
+ ARG REPO_REF=main
7
+
8
+ # --- Stage 1: build the Next.js static export ---
9
+ FROM node:20-bookworm-slim AS ui-build
10
+ ARG REPO_URL
11
+ ARG REPO_REF
12
+ WORKDIR /src
13
+ RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates \
14
+ && rm -rf /var/lib/apt/lists/*
15
+ RUN git clone --depth 1 --branch ${REPO_REF} ${REPO_URL} app
16
+ WORKDIR /src/app/ui
17
+ RUN npm install --no-audit --no-fund
18
+ RUN NEXT_OUTPUT=export npm run build
19
+
20
+ # --- Stage 2: Python runtime serving API + static UI ---
21
+ FROM python:3.12-slim AS runtime
22
+ ARG REPO_URL
23
+ ARG REPO_REF
24
+
25
+ ENV PYTHONUNBUFFERED=1 \
26
+ PYTHONDONTWRITEBYTECODE=1 \
27
+ PIP_NO_CACHE_DIR=1 \
28
+ HF_HOME=/data/hf-cache \
29
+ FMODETECT_STATIC=/data/static \
30
+ PYTHONPATH=/app
31
+
32
+ WORKDIR /app
33
+
34
+ RUN apt-get update && apt-get install -y --no-install-recommends \
35
+ git ca-certificates libgl1 libglib2.0-0 ffmpeg \
36
+ && rm -rf /var/lib/apt/lists/*
37
+
38
+ # Clone source at build time (overlaid in the next step with the UI build).
39
+ RUN git clone --depth 1 --branch ${REPO_REF} ${REPO_URL} /app && \
40
+ rm -rf /app/ui && mkdir -p /app/ui
41
+
42
+ # Bring in the built static export from stage 1.
43
+ COPY --from=ui-build /src/app/ui/out /app/ui/out
44
+
45
+ # Install deploy-only requirements (CPU torch).
46
+ COPY requirements.txt /tmp/requirements.txt
47
+ RUN pip install -r /tmp/requirements.txt
48
+
49
+ # Writable runtime dirs for HF cache and generated overlays.
50
+ RUN mkdir -p /data/hf-cache /data/static && chmod -R 777 /data
51
+
52
+ EXPOSE 7860
53
+ CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]
README.md CHANGED
@@ -1,10 +1,43 @@
1
  ---
2
- title: Fmodetect V2
3
- emoji: πŸ‘
4
- colorFrom: blue
5
  colorTo: indigo
6
  sdk: docker
 
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: FMODetect v2
3
+ emoji: πŸŒ€
4
+ colorFrom: gray
5
  colorTo: indigo
6
  sdk: docker
7
+ app_port: 7860
8
  pinned: false
9
+ license: mit
10
+ short_description: Fast-moving-object detection from a single blurred frame
11
  ---
12
 
13
+ # FMODetect v2 β€” research demo
14
+
15
+ PyTorch re-implementation of [FMODetect (Rozumnyi et al., ICCV 2021)](https://arxiv.org/abs/2012.08216)
16
+ with three additions: CBAM attention, a joint TDF + matting head, and an
17
+ uncertainty-weighted boundary loss.
18
+
19
+ Source: <https://github.com/jai-krishna-0921/FMODetect-v2>
20
+
21
+ ## How this Space is built
22
+
23
+ This Space contains only a `Dockerfile`, a `requirements.txt` and this README.
24
+ At build time the Dockerfile clones the source repo, builds the Next.js UI as
25
+ a static export, and serves it from FastAPI on port 7860.
26
+
27
+ ## Environment
28
+
29
+ Set these in the Space settings β†’ Variables and secrets:
30
+
31
+ | key | value |
32
+ |--------------------------|----------------------------------------|
33
+ | `FMODETECT_HF_REPO` | `<your-username>/fmodetect-v2` |
34
+ | `FMODETECT_HF_FILENAME` | `best.pt` (default; only set to override) |
35
+
36
+ The checkpoint is downloaded once at first request and cached on the Space
37
+ disk. To swap models, upload a new file to the HF Hub model repo and restart
38
+ the Space.
39
+
40
+ ## Hardware
41
+
42
+ CPU Basic (free) runs inference in ~2–3 s per image pair. T4 small (~$0.40/hr)
43
+ brings it under 200 ms.
requirements.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CPU-only deploy dependencies for the Hugging Face Space.
2
+ # Pinned to a slim runtime set β€” no training / experiment-tracking deps.
3
+ --extra-index-url https://download.pytorch.org/whl/cpu
4
+ torch==2.12.0+cpu
5
+ torchvision==0.27.0+cpu
6
+ numpy>=2.1
7
+ scipy>=1.14
8
+ scikit-image>=0.25
9
+ opencv-python-headless>=4.10
10
+ imageio[ffmpeg]>=2.36
11
+ pillow>=11
12
+ fastapi>=0.115
13
+ uvicorn[standard]>=0.32
14
+ python-multipart>=0.0.20
15
+ huggingface_hub>=0.26