isl-detection / start_gesture.py
Deepak Roshan
final fix: gesture detection working + threshold + UI camera fix
f5f47c6
Raw
History Blame Contribute Delete
3.03 kB
# start_gesture.py
# ─────────────────────────────────────────────────────────────
# CLOUD mode entry point for HuggingFace Spaces (supervisord).
#
# ARCHITECTURE (single process):
# 1. Creates SharedState (stdlib queue β€” no Manager, no IPC)
# 2. Passes it to dashboard_process()
# 3. dashboard_process() assigns it to _shared_state module global
# AND starts core_processing_engine() as a daemon thread
# 4. on_browser_frame() writes to _shared_state via put_frame()
# 5. core_processing_engine() reads via take_frame()
#
# β˜… KEY: SharedState is created ONCE here and passed all the way through.
# There is no second SharedState anywhere β€” same object, same queue.
# ─────────────────────────────────────────────────────────────
import os
import sys
import time
os.environ["RUN_MODE"] = "CLOUD"
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
os.environ["PYTHONUNBUFFERED"] = "1"
print("=" * 60, flush=True)
print("🌐 ISL Gesture Dashboard starting (CLOUD mode)…", flush=True)
print("=" * 60, flush=True)
# ── Import SharedState ────────────────────────────────────────
try:
from isl_detection import SharedState
print("βœ… SharedState imported", flush=True)
except Exception as e:
print(f"❌ IMPORT ERROR (SharedState): {e}", flush=True)
import traceback; traceback.print_exc()
sys.exit(1)
# ── Import dashboard_process ──────────────────────────────────
try:
from isl_ui_dashboard import dashboard_process
print("βœ… dashboard_process imported", flush=True)
except Exception as e:
print(f"❌ IMPORT ERROR (dashboard_process): {e}", flush=True)
import traceback; traceback.print_exc()
sys.exit(1)
# ── Create SharedState (single instance) ─────────────────────
try:
shared_state = SharedState()
print("βœ… SharedState created (queue.Queue β€” no IPC)", flush=True)
except Exception as e:
print(f"❌ SharedState init error: {e}", flush=True)
import traceback; traceback.print_exc()
sys.exit(1)
# ── Launch ────────────────────────────────────────────────────
print("πŸš€ Calling dashboard_process (port 5000)…", flush=True)
try:
dashboard_process(
shared_state=shared_state,
shm_name=None,
frame_lock_val=None,
frame_seq=None,
)
except Exception as e:
print(f"❌ dashboard_process CRASHED: {e}", flush=True)
import traceback; traceback.print_exc()
sys.exit(1)