Spaces:
Configuration error
Configuration error
Restore CPU Basic compatibility and remove Usage tab
Browse files
README.md
CHANGED
|
@@ -22,4 +22,4 @@ Notes:
|
|
| 22 |
|
| 23 |
- CPU Basic can be slow for YOLO11x, so the default settings process a limited number of frames.
|
| 24 |
- Increase `Max frames` or lower `Frame stride` for more complete output.
|
| 25 |
-
-
|
|
|
|
| 22 |
|
| 23 |
- CPU Basic can be slow for YOLO11x, so the default settings process a limited number of frames.
|
| 24 |
- Increase `Max frames` or lower `Frame stride` for more complete output.
|
| 25 |
+
- This version is configured for the free CPU Basic hardware. YOLO11x processing can be slow, so select a short clip before processing.
|
app.py
CHANGED
|
@@ -18,19 +18,6 @@ from importlib import metadata
|
|
| 18 |
from pathlib import Path
|
| 19 |
from urllib.parse import quote
|
| 20 |
|
| 21 |
-
# ZeroGPU requires importing `spaces` before any CUDA-related package touches CUDA.
|
| 22 |
-
try:
|
| 23 |
-
import spaces
|
| 24 |
-
except ImportError:
|
| 25 |
-
class _SpacesCompat:
|
| 26 |
-
def GPU(self, *args, **kwargs):
|
| 27 |
-
def decorator(fn):
|
| 28 |
-
return fn
|
| 29 |
-
|
| 30 |
-
return decorator
|
| 31 |
-
|
| 32 |
-
spaces = _SpacesCompat()
|
| 33 |
-
|
| 34 |
import cv2
|
| 35 |
import gradio as gr
|
| 36 |
import matplotlib
|
|
@@ -74,7 +61,6 @@ logging.basicConfig(
|
|
| 74 |
logger = logging.getLogger(__name__)
|
| 75 |
|
| 76 |
FFMPEG_TIMEOUT_SECONDS = int(os.getenv("FFMPEG_TIMEOUT_SECONDS", "180"))
|
| 77 |
-
ZERO_GPU_DURATION_SECONDS = int(os.getenv("ROWING_ZERO_GPU_DURATION", "300"))
|
| 78 |
|
| 79 |
WEIGHT_DIR = SCRIPT_DIR / "Weight"
|
| 80 |
YOLO_MODEL_PATH = WEIGHT_DIR / "yolo11x-pose.pt"
|
|
@@ -610,8 +596,7 @@ def choose_device() -> torch.device:
|
|
| 610 |
|
| 611 |
|
| 612 |
def choose_ae_device() -> torch.device:
|
| 613 |
-
#
|
| 614 |
-
# lightweight, so CPU is the safest default on Spaces and avoids CUDA init errors.
|
| 615 |
force_cpu_default = bool(os.getenv("SPACE_ID"))
|
| 616 |
if env_flag("ROWING_AE_FORCE_CPU", force_cpu_default):
|
| 617 |
return torch.device("cpu")
|
|
@@ -1808,7 +1793,6 @@ def create_monitored_clip(
|
|
| 1808 |
return str(clip_path), str(clip_path), summary
|
| 1809 |
|
| 1810 |
|
| 1811 |
-
@spaces.GPU(duration=ZERO_GPU_DURATION_SECONDS)
|
| 1812 |
def build_stickman_video(
|
| 1813 |
video_path,
|
| 1814 |
clip_path,
|
|
@@ -3993,10 +3977,11 @@ with gr.Blocks(title="RowingValidator Beta - AI Rowing Analysis") as demo:
|
|
| 3993 |
error_stats_md = gr.Markdown("### 错误分布统计")
|
| 3994 |
error_stats_output = gr.HTML()
|
| 3995 |
|
| 3996 |
-
|
| 3997 |
-
|
| 3998 |
-
|
| 3999 |
-
|
|
|
|
| 4000 |
|
| 4001 |
|
| 4002 |
# 辅助函数
|
|
@@ -4543,8 +4528,8 @@ function inferCurrentLangFromButton() {
|
|
| 4543 |
function applyTabLabels() {
|
| 4544 |
const lang = inferCurrentLangFromButton();
|
| 4545 |
const labels = lang === 'en'
|
| 4546 |
-
? ['Home', 'Tool', 'Video Process', 'Compare', 'Report'
|
| 4547 |
-
: ['首页', '工具', '视频处理', '动作对比', '诊断报告'
|
| 4548 |
const buttons = Array.from(document.querySelectorAll('button')).filter(b => !b.closest('.global-language-toggle'));
|
| 4549 |
const patterns = [
|
| 4550 |
['首页', 'Home'],
|
|
@@ -4552,7 +4537,6 @@ function applyTabLabels() {
|
|
| 4552 |
['视频处理', 'Video Process', 'Process'],
|
| 4553 |
['动作对比', 'Compare'],
|
| 4554 |
['诊断报告', 'Report'],
|
| 4555 |
-
['使用统计', 'Usage'],
|
| 4556 |
];
|
| 4557 |
patterns.forEach((pattern, idx) => {
|
| 4558 |
const btn = buttons.find(b => pattern.some(p => b.textContent.includes(p)));
|
|
|
|
| 18 |
from pathlib import Path
|
| 19 |
from urllib.parse import quote
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
import cv2
|
| 22 |
import gradio as gr
|
| 23 |
import matplotlib
|
|
|
|
| 61 |
logger = logging.getLogger(__name__)
|
| 62 |
|
| 63 |
FFMPEG_TIMEOUT_SECONDS = int(os.getenv("FFMPEG_TIMEOUT_SECONDS", "180"))
|
|
|
|
| 64 |
|
| 65 |
WEIGHT_DIR = SCRIPT_DIR / "Weight"
|
| 66 |
YOLO_MODEL_PATH = WEIGHT_DIR / "yolo11x-pose.pt"
|
|
|
|
| 596 |
|
| 597 |
|
| 598 |
def choose_ae_device() -> torch.device:
|
| 599 |
+
# The autoencoder is lightweight; keep it on CPU in Spaces to reduce memory use.
|
|
|
|
| 600 |
force_cpu_default = bool(os.getenv("SPACE_ID"))
|
| 601 |
if env_flag("ROWING_AE_FORCE_CPU", force_cpu_default):
|
| 602 |
return torch.device("cpu")
|
|
|
|
| 1793 |
return str(clip_path), str(clip_path), summary
|
| 1794 |
|
| 1795 |
|
|
|
|
| 1796 |
def build_stickman_video(
|
| 1797 |
video_path,
|
| 1798 |
clip_path,
|
|
|
|
| 3977 |
error_stats_md = gr.Markdown("### 错误分布统计")
|
| 3978 |
error_stats_output = gr.HTML()
|
| 3979 |
|
| 3980 |
+
# Keep usage tracking connected to existing callbacks without exposing
|
| 3981 |
+
# a user-facing Usage tab.
|
| 3982 |
+
usage_title_md = gr.Markdown("", visible=False)
|
| 3983 |
+
usage_stats_output = gr.HTML(usage_summary_html(), visible=False)
|
| 3984 |
+
refresh_usage_button = gr.Button("", visible=False)
|
| 3985 |
|
| 3986 |
|
| 3987 |
# 辅助函数
|
|
|
|
| 4528 |
function applyTabLabels() {
|
| 4529 |
const lang = inferCurrentLangFromButton();
|
| 4530 |
const labels = lang === 'en'
|
| 4531 |
+
? ['Home', 'Tool', 'Video Process', 'Compare', 'Report']
|
| 4532 |
+
: ['首页', '工具', '视频处理', '动作对比', '诊断报告'];
|
| 4533 |
const buttons = Array.from(document.querySelectorAll('button')).filter(b => !b.closest('.global-language-toggle'));
|
| 4534 |
const patterns = [
|
| 4535 |
['首页', 'Home'],
|
|
|
|
| 4537 |
['视频处理', 'Video Process', 'Process'],
|
| 4538 |
['动作对比', 'Compare'],
|
| 4539 |
['诊断报告', 'Report'],
|
|
|
|
| 4540 |
];
|
| 4541 |
patterns.forEach((pattern, idx) => {
|
| 4542 |
const btn = buttons.find(b => pattern.some(p => b.textContent.includes(p)));
|