Spaces:
Sleeping
Sleeping
change dataset config
Browse filesFiles changed (6)
- README.md+20
- app.py+4-2
- backup/2025-10-23/new_user.jsonDeleted-1
- backup/2025-10-23/test_user_1.jsonDeleted-1
- backup/2025-10-23/test_user_2.jsonDeleted-1
- test_api.sh+39-56
8 unmodified lines9101112131415161718192021222324252627282930318 unmodified linespinned: falselicense: apache-2.0---
# MuscleCare Dataset API
μ΄ Spaceλ μμ§λ μ΄λ νΌλ‘λ λ°μ΄ν°λ₯Ό Hugging Face Dataset μ μ₯μμ μ
λ‘λνλ FastAPI μλΉμ€λ₯Ό μ 곡ν©λλ€.
## μλν¬μΈνΈ- `GET /health` : μλ² μν νμΈ- `POST /upload_dataset` : `fatigue_dataset` μ€ν€λ§μ λ§μΆ λ°°μΉ λ°μ΄ν°λ₯Ό Hugging Face Hubλ‘ μ μ₯
## μ€ν λ°©λ²```bash./start_server.sh```
## ν
μ€νΈ```bash./test_api.sh```
ν
μ€νΈ μ€ν¬λ¦½νΈλ μν λ°°μΉ λ°μ΄ν°λ₯Ό `/upload_dataset` μλν¬μΈνΈλ‘ μ μ‘ν©λλ€. μ€ν μ `HF_DATA_REPO_ID`μ `HF_DATA_TOKEN` νκ²½λ³μκ° μ€μ λμ΄ μμ΄μΌ ν©λλ€.17 unmodified lines18192021212223242587 unmodified lines11311411511611711811981 unmodified lines20120220320220420520620717 unmodified lines
# ----- λͺ¨λΈ -----class DatasetItem(BaseModel): id: Optional[int] = None user_id: int user_id: str session_id: Optional[str] = None window_id: int window_start_ms: int87 unmodified lines
# μ μ€ν€λ§ μ μ target_cols = [ "id", "user_id", "session_id", "window_id",81 unmodified lines rec = item.model_dump() if not rec.get("timestamp_utc"): rec["timestamp_utc"] = datetime.now().isoformat() user_groups.setdefault(str(item.user_id), []).append(rec) user_groups.setdefault(item.user_id, []).append(rec)
results = {}
1[{"user_id": "new_user", "rms": 0.95, "freq": 60.1, "fatigue": 0.88, "timestamp": "2025-10-23T15:02:00.000000"}]1[{"user_id": "test_user_1", "rms": 0.85, "freq": 52.3, "fatigue": 0.72, "timestamp": "2025-10-23T14:55:00.000000"}]1[{"user_id": "test_user_2", "rms": 0.91, "freq": 58.7, "fatigue": 0.81, "timestamp": "2025-10-23T14:55:30.000000"}]112343 unmodified lines891011111213146 unmodified lines2122232425242526272728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808131323334353637383940414243444546474849505152535455565758596061626364656667γ
γ
#!/bin/bash#!/bin/bash
# MuscleCare API ν
μ€νΈ μ€ν¬λ¦½νΈ
3 unmodified linesBASE_URL="${1:-http://localhost:7860}"
echo "======================================"echo "π§ͺ MuscleCare API ν
μ€νΈ"echo "π§ͺ MuscleCare Dataset API ν
μ€νΈ"echo "======================================"echo "μλ²: $BASE_URL"echo ""6 unmodified linesecho ""echo ""
# 2. μ¬μ©μ μν μ
λ‘λecho "2οΈβ£ μ¬μ©μ μν μ
λ‘λ"# 2. λ°°μΉ λ°μ΄ν° μ
λ‘λecho "2οΈβ£ λ°°μΉ λ°μ΄ν° μ
λ‘λ"echo "--------------------------------------"curl -X POST "$BASE_URL/upload_state" \curl -X POST "$BASE_URL/upload_dataset" \ -H "Content-Type: application/json" \ -H "accept: application/json" \ -d '{ "user_id": "local_user", "rms_base": 0.11, "freq_base": 50.1, "user_emb": [0.135, 0.012, 49.3, 0.8, 0.84, 0.02, 0.11, 0.0021, 0.35, 0.71, 0.92, 0.88], "model_version": "v1.0.0" }' | jq .echo ""echo ""
# 3. λ‘κ·Έ λ°μ΄ν° μ
λ‘λ (μλ‘μ΄ κ°λ³ API)echo "3οΈβ£ λ‘κ·Έ λ°μ΄ν° μ
λ‘λ"echo "--------------------------------------"curl -X POST "$BASE_URL/upload_logs" \ -H "Content-Type: application/json" \ -H "accept: application/json" \ -d '{ "user_id": "test_user_001", "session_id": "session_123", "measure_date": "2025-10-24", "rms": 0.42, "freq": 45.3, "fatigue": 0.25, "rms_base": 0.40, "freq_base": 44.8, "user_emb": [0.2, 0.05, 45.1, 0.7, 0.8, 0.03, 0.12, 0.0015, 0.4, 0.75, 0.9, 0.85], "mode": "training", "window_count": 5, "measurement_count": 1 }' | jq .echo ""echo ""
# 4. μΆκ° λ‘κ·Έ λ°μ΄ν° μ
λ‘λecho "4οΈβ£ μΆκ° λ‘κ·Έ λ°μ΄ν° μ
λ‘λ"echo "--------------------------------------"curl -X POST "$BASE_URL/upload_logs" \ -H "Content-Type: application/json" \ -H "accept: application/json" \ -d '{ "user_id": "test_user_001", "session_id": "session_124", "measure_date": "2025-10-24", "rms": 0.38, "freq": 46.1, "fatigue": 0.32, "rms_base": 0.40, "freq_base": 44.8, "user_emb": [0.22, 0.06, 45.5, 0.72, 0.82, 0.035, 0.13, 0.0018, 0.42, 0.77, 0.92, 0.87], "mode": "testing", "window_count": 7, "measurement_count": 1 "batch_data": [ { "user_id": "user_001", "session_id": "session_001", "window_id": 1001, "window_start_ms": 0, "window_end_ms": 2000, "timestamp_utc": "2025-10-24T10:00:00Z", "acc_x_mean": 0.01, "acc_y_mean": -0.02, "acc_z_mean": 0.98, "gyro_x_mean": 0.001, "gyro_y_mean": -0.003, "gyro_z_mean": 0.002, "rms_acc": 0.45, "rms_gyro": 0.12, "mean_freq_acc": 45.2, "mean_freq_gyro": 12.5, "entropy_acc": 0.62, "entropy_gyro": 0.31, "jerk_mean": 0.08, "jerk_std": 0.01, "stability_index": 0.9, "rms_base": 0.4, "freq_base": 40.0, "user_emb": [0.1, 0.05, 0.02, 0.07, 0.11, 0.03, 0.04, 0.02, 0.09, 0.01, 0.08, 0.05], "fatigue_prev": 0.3, "fatigue": 0.32, "fatigue_level": 1, "quality_flag": 1, "window_size_ms": 2000, "overlap_rate": 0.5 } ] }' | jq .echo ""echo ""README.md+20
app.py+4-2
backup/2025-10-23/new_user.jsonDeleted-1
backup/2025-10-23/test_user_1.jsonDeleted-1
backup/2025-10-23/test_user_2.jsonDeleted-1
test_api.sh+39-56