YoungjaeDev Claude commited on
Commit
7ea83d4
·
1 Parent(s): 2980d63

feat: HF Space 배포용 모델 및 샘플 영상 준비

Browse files

- Private HF Model 저장소 생성 (YoungjaeDev/fall-detection-models)
- yolo11m-pose.pt (~41MB)
- best_acc.pth (~37MB)

- app.py 수정: hf_hub_download 방식으로 모델 로드 변경
- 로컬 개발 시 로컬 파일 우선 사용
- HF Spaces에서는 Private repo에서 자동 다운로드 (HF_TOKEN 필요)

- 샘플 영상 6개 추가 (Git LFS)
- 병원: 00050_H_A_BY_C1.mp4, 00050_H_A_BY_C2.mp4
- 노인정: 01602_L_F_BY_C2.mp4, 01823_Y_A_BY_C4.mp4
- 집: 00750_O_E_BY_C1.mp4, 00750_O_E_BY_C2.mp4

- .gitattributes: mp4 파일 Git LFS 추적 설정
- .gitignore: demo_gradio/examples/*.mp4 예외 추가
- README.md: 모델 저장소 정보 및 로컬 실행 가이드 추가

Closes #72

Co-Authored-By: Claude <noreply@anthropic.com>

.gitattributes ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Git LFS tracking for large files
2
+ *.mp4 filter=lfs diff=lfs merge=lfs -text
3
+ *.avi filter=lfs diff=lfs merge=lfs -text
4
+ *.mov filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -51,16 +51,29 @@ YOLOv11-Pose + ST-GCN 2-stage 파이프라인을 사용한 실시간 낙상 감
51
  - **Latency**: ~2초 (60 프레임 윈도우 기준)
52
  - **Accuracy**: 99.6% (AI Hub 검증 데이터셋)
53
 
 
 
 
 
 
 
 
 
54
  ## 로컬 실행
55
 
56
  ```bash
57
  # 의존성 설치
58
  pip install -r requirements.txt
59
 
 
 
 
60
  # 앱 실행
61
  python app.py
62
  ```
63
 
 
 
64
  ## 참고자료
65
 
66
  - [YOLOv11 (Ultralytics)](https://github.com/ultralytics/ultralytics)
 
51
  - **Latency**: ~2초 (60 프레임 윈도우 기준)
52
  - **Accuracy**: 99.6% (AI Hub 검증 데이터셋)
53
 
54
+ ## 모델 저장소
55
+
56
+ 모델 파일은 Private HuggingFace Model 저장소에서 자동으로 다운로드됩니다.
57
+
58
+ - **저장소**: `YoungjaeDev/fall-detection-models` (Private)
59
+ - **파일**: `yolo11m-pose.pt`, `best_acc.pth`
60
+ - **토큰**: HF Spaces의 경우 `HF_TOKEN` Secret 설정 필요
61
+
62
  ## 로컬 실행
63
 
64
  ```bash
65
  # 의존성 설치
66
  pip install -r requirements.txt
67
 
68
+ # HuggingFace 로그인 (Private 모델 접근용)
69
+ huggingface-cli login
70
+
71
  # 앱 실행
72
  python app.py
73
  ```
74
 
75
+ 로컬 개발 시 프로젝트 루트에 `yolo11m-pose.pt`와 `runs/stgcn_binary_exp2_fixed_graph/best_acc.pth`가 있으면 HF에서 다운로드하지 않고 로컬 파일을 사용합니다.
76
+
77
  ## 참고자료
78
 
79
  - [YOLOv11 (Ultralytics)](https://github.com/ultralytics/ultralytics)
app.py CHANGED
@@ -30,6 +30,7 @@ import plotly.graph_objects as go
30
  import torch
31
  from gradio.themes import Soft
32
  from gradio.themes.utils import colors, fonts, sizes
 
33
 
34
  # 프로젝트 루트를 Python path에 추가
35
  # pipeline/demo_gradio/app.py -> pipeline -> project_root
@@ -142,6 +143,44 @@ def gpu_decorator(duration: int = 120):
142
  return decorator
143
 
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  # -----------------------------------------------------------------------------
146
  # 파이프라인 초기화 (지연 로딩)
147
  # -----------------------------------------------------------------------------
@@ -154,15 +193,8 @@ def get_pipeline():
154
  if _pipeline is None:
155
  from pipeline.core.pipeline import FallDetectionPipeline
156
 
157
- # HF Spaces에서는 models 폴더에서 로드
158
- pose_model_path = "pipeline/demo_gradio/models/yolo11m-pose.pt"
159
- stgcn_checkpoint = "pipeline/demo_gradio/models/best_acc.pth"
160
-
161
- # 로컬 경로 폴백
162
- if not Path(pose_model_path).exists():
163
- pose_model_path = "yolo11m-pose.pt"
164
- if not Path(stgcn_checkpoint).exists():
165
- stgcn_checkpoint = "runs/stgcn_binary_exp2_fixed_graph/best_acc.pth"
166
 
167
  _pipeline = FallDetectionPipeline(
168
  pose_model_path=pose_model_path,
 
30
  import torch
31
  from gradio.themes import Soft
32
  from gradio.themes.utils import colors, fonts, sizes
33
+ from huggingface_hub import hf_hub_download
34
 
35
  # 프로젝트 루트를 Python path에 추가
36
  # pipeline/demo_gradio/app.py -> pipeline -> project_root
 
143
  return decorator
144
 
145
 
146
+ # -----------------------------------------------------------------------------
147
+ # 모델 다운로드 (HuggingFace Hub)
148
+ # -----------------------------------------------------------------------------
149
+ HF_MODEL_REPO = "YoungjaeDev/fall-detection-models"
150
+
151
+
152
+ def download_models() -> tuple[str, str]:
153
+ """
154
+ HuggingFace Hub에서 모델 다운로드 (캐시됨)
155
+
156
+ Returns:
157
+ tuple: (pose_model_path, stgcn_checkpoint_path)
158
+ """
159
+ # 로컬 경로 우선 확인 (개발 환경)
160
+ local_pose = Path("yolo11m-pose.pt")
161
+ local_stgcn = Path("runs/stgcn_binary_exp2_fixed_graph/best_acc.pth")
162
+
163
+ if local_pose.exists() and local_stgcn.exists():
164
+ return str(local_pose), str(local_stgcn)
165
+
166
+ # HuggingFace Hub에서 다운로드 (Private repo는 HF_TOKEN 환경변수 필요)
167
+ token = os.environ.get("HF_TOKEN")
168
+
169
+ pose_model_path = hf_hub_download(
170
+ repo_id=HF_MODEL_REPO,
171
+ filename="yolo11m-pose.pt",
172
+ token=token
173
+ )
174
+
175
+ stgcn_checkpoint = hf_hub_download(
176
+ repo_id=HF_MODEL_REPO,
177
+ filename="best_acc.pth",
178
+ token=token
179
+ )
180
+
181
+ return pose_model_path, stgcn_checkpoint
182
+
183
+
184
  # -----------------------------------------------------------------------------
185
  # 파이프라인 초기화 (지연 로딩)
186
  # -----------------------------------------------------------------------------
 
193
  if _pipeline is None:
194
  from pipeline.core.pipeline import FallDetectionPipeline
195
 
196
+ # 모델 다운로드 (캐시됨)
197
+ pose_model_path, stgcn_checkpoint = download_models()
 
 
 
 
 
 
 
198
 
199
  _pipeline = FallDetectionPipeline(
200
  pose_model_path=pose_model_path,
examples/.gitkeep DELETED
File without changes
examples/00050_H_A_BY_C1.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9b8a0348200c40663bb852f4c590470ed95f43cf0cdb5c184eb69601b34c99e
3
+ size 13167084
examples/00050_H_A_BY_C2.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a49cc52f966b4532590e0e3f4b3303304c64bd3812fb86a05a445756f4ebb8bb
3
+ size 13299992
examples/00750_O_E_BY_C1.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b2473e3c40d6eb09b6343a17a19a4deebc1118c709eb4b5c8df1935ced9198d
3
+ size 12700514
examples/00750_O_E_BY_C2.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09d4530baeefa30a00cabea8823663b1f126599b9a7327f8619b8170d81b0a07
3
+ size 13285269
examples/01602_L_F_BY_C2.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7997c263b35c33bdcf4daa9caee37c70eaf864ca68a1d55306a82f7e2f184183
3
+ size 13820623
examples/01823_Y_A_BY_C4.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:adf7972e75d173c659f343d19a97cb1de0f533f4a46dc3555a4bd4002726a305
3
+ size 10517437
models/.gitkeep DELETED
File without changes