diff --git a/.gitattributes b/.gitattributes index a6344aac8c09253b3b630fb776ae94478aa0275b..0ecb12fc1b0161f223a066e2732ab9caada6082b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,35 +1,6 @@ -*.7z filter=lfs diff=lfs merge=lfs -text -*.arrow filter=lfs diff=lfs merge=lfs -text -*.bin filter=lfs diff=lfs merge=lfs -text -*.bz2 filter=lfs diff=lfs merge=lfs -text -*.ckpt filter=lfs diff=lfs merge=lfs -text -*.ftz filter=lfs diff=lfs merge=lfs -text -*.gz filter=lfs diff=lfs merge=lfs -text -*.h5 filter=lfs diff=lfs merge=lfs -text -*.joblib filter=lfs diff=lfs merge=lfs -text -*.lfs.* filter=lfs diff=lfs merge=lfs -text -*.mlmodel filter=lfs diff=lfs merge=lfs -text -*.model filter=lfs diff=lfs merge=lfs -text -*.msgpack filter=lfs diff=lfs merge=lfs -text -*.npy filter=lfs diff=lfs merge=lfs -text -*.npz filter=lfs diff=lfs merge=lfs -text -*.onnx filter=lfs diff=lfs merge=lfs -text -*.ot filter=lfs diff=lfs merge=lfs -text -*.parquet filter=lfs diff=lfs merge=lfs -text -*.pb filter=lfs diff=lfs merge=lfs -text -*.pickle filter=lfs diff=lfs merge=lfs -text -*.pkl filter=lfs diff=lfs merge=lfs -text -*.pt filter=lfs diff=lfs merge=lfs -text -*.pth filter=lfs diff=lfs merge=lfs -text -*.rar filter=lfs diff=lfs merge=lfs -text -*.safetensors filter=lfs diff=lfs merge=lfs -text -saved_model/**/* filter=lfs diff=lfs merge=lfs -text -*.tar.* filter=lfs diff=lfs merge=lfs -text -*.tar filter=lfs diff=lfs merge=lfs -text -*.tflite filter=lfs diff=lfs merge=lfs -text -*.tgz filter=lfs diff=lfs merge=lfs -text -*.wasm filter=lfs diff=lfs merge=lfs -text -*.xz filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.zst filter=lfs diff=lfs merge=lfs -text -*tfevents* filter=lfs diff=lfs merge=lfs -text +*.mp4 filter=lfs diff=lfs merge=lfs -text +*.webm filter=lfs diff=lfs merge=lfs -text +web/dist/media/posters/cat-active.jpg filter=lfs diff=lfs merge=lfs -text +web/dist/media/posters/pkg-arrive.jpg filter=lfs diff=lfs merge=lfs -text +web/dist/media/posters/pkg-taken.jpg filter=lfs diff=lfs merge=lfs -text +web/dist/media/posters/porch-empty.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/MEDIA-SOURCES.md b/MEDIA-SOURCES.md new file mode 100644 index 0000000000000000000000000000000000000000..0f08f1dde874be147d254617f7c2778f8d0dd493 --- /dev/null +++ b/MEDIA-SOURCES.md @@ -0,0 +1,61 @@ +# Sample video sources + +Short clips supplied for this household-observation evaluation. Source links are retained for attribution. Original videos and datasets have not been modified. + +| Clip | Title | Source | +|---|---|---| +| smartbench_0133 | 宠物在客厅活动 | https://www.youtube.com/watch?v=jR4r4-sV5sU | +| smartbench_0880 | 空客厅后宠物进入 | https://www.youtube.com/watch?v=v5aU-eSFzK4 | +| smartbench_0036 | 人与宠物日常互动 | https://www.youtube.com/watch?v=c4BiMNV5dME | +| smartbench_0188 | 幼犬翻越围栏 | https://www.youtube.com/watch?v=uUsuo2hKqnQ | +| smartbench_0630 | 宠物撕咬纸巾 | https://www.youtube.com/watch?v=IAUXOVtZqNk | +| smartbench_0276 | 配送员放下包裹 | https://www.youtube.com/watch?v=_iV2anL2SKE | +| smartbench_0266 | 住户取走包裹 | https://www.youtube.com/watch?v=_xg3SH6qu1c | +| smartbench_0551 | 门口人员拆开包裹 | https://www.youtube.com/watch?v=EXEg6CfzW70 | +| smartbench_0216 | 住户离开后空门廊 | https://www.youtube.com/watch?v=OvBzOodJ31E | +| smartbench_0321 | 人与宠物回屋后空门廊 | https://www.youtube.com/watch?v=FuDb8E9G6q4 | +| smartbench_0083 | 夜间人员进入后院 | https://www.youtube.com/watch?v=yT7qfBXOGLw | +| smartbench_0094 | 夜间人员进入围栏庭院 | https://www.youtube.com/watch?v=ArFLLlLjfXw | +| smartbench_0007 | 熊进入后院翻垃圾桶 | https://www.youtube.com/watch?v=GfNH24LsSh8 | +| smartbench_0058 | 人与狗在院内活动 | https://www.youtube.com/watch?v=TnjOgP6IvU8 | +| smartbench_0290 | 后院鸟类在喂食器活动 | https://www.youtube.com/watch?v=XWCCEksks5U | +| smartbench_0643 | 住户回屋后空庭院门口 | https://www.youtube.com/watch?v=5Xy1MJ6hXKc | +| negative_01 | 沙发区无人活动_纸袋与箱子保持不变 | https://changedetection.net/dataset2014/ | +| negative_02 | 沙发区无人活动_箱子保持不变 | https://changedetection.net/dataset2014/ | +| negative_03 | 人和宠物回屋后空门廊 | https://www.youtube.com/watch?v=FuDb8E9G6q4 | +| negative_04 | 夜间人员离开后空庭院 | https://www.youtube.com/watch?v=ArFLLlLjfXw | +| negative_05 | 白天住户回屋后空庭院 | https://www.youtube.com/watch?v=5Xy1MJ6hXKc | +| negative_06 | 室外入口无人员_树影自然变化 | https://changedetection.net/dataset2014/ | +| S01 | 住户带包离家与门边钥匙动作 | https://www.youtube.com/watch?v=jNsO1K0mRwI | +| S02 | 住户带包靠近门并进屋 | https://www.youtube.com/watch?v=fyeQn4V8cHU | +| S03 | 孩子背书包离家_到家反例 | https://www.youtube.com/watch?v=z-TMWr0axSo | +| S04 | 放学儿童在门口交谈 | https://www.youtube.com/watch?v=CSM5AuDQzwc | +| S05 | 校车旁儿童回到门廊 | https://www.youtube.com/watch?v=X5sIOHuLyAw | +| S06 | 背书包儿童进入室内 | https://www.youtube.com/watch?v=-3yHkj7dPvA | +| S07 | 儿童入户后受惊跌倒_终态反例 | https://www.youtube.com/watch?v=-3yHkj7dPvA | +| S08 | 门廊清扫过程 | https://www.youtube.com/watch?v=sZ9ij4A0REg | +| S09 | 远处吸尘动作_微小目标无法确认 | https://www.youtube.com/watch?v=_Psi3NnuNiw | +| S10 | 宠物休息与扫地机器人活动 | https://www.youtube.com/watch?v=6xZVT_HphuM | +| S11 | 夜视猫进食并间歇抬头 | https://www.youtube.com/watch?v=17_N3EJXNwg | +| S12 | 猫在食盆旁抬头暂停_进食对照 | https://www.youtube.com/watch?v=17_N3EJXNwg | +| S13 | 两只猫在食盆附近互动 | https://www.youtube.com/watch?v=bK0HH-YZTQ4 | +| S14 | 松鼠翻动门口零食篮 | https://www.youtube.com/watch?v=M-R95X8bk94 | +| S15 | 狗咬鞋_与玩具区分 | https://www.youtube.com/watch?v=qPVd5EP6vRQ | +| S16 | 宠物贴近镜头造成遮挡 | https://www.youtube.com/watch?v=qPVd5EP6vRQ | +| S17 | 猫在玩具旁休息 | https://www.youtube.com/watch?v=nVkLviQSlcY | +| S18 | 猫贴镜头_视野与夜视切换 | https://www.youtube.com/watch?v=nVkLviQSlcY | +| S19 | 夜间蜘蛛靠近镜头 | https://www.youtube.com/watch?v=BiE85wTQvpE | +| S20 | 狗下桌后遮挡镜头 | https://www.youtube.com/watch?v=3AwEol8eZ0M | +| S21 | 院内晾衣被逐件收下 | https://www.youtube.com/watch?v=Kdefe5JM0xM | +| S22 | 乌龟推开庭院门后离开 | https://www.youtube.com/watch?v=lPfU3YZaCes | +| S23 | 宠物店监控_手部遮住微小乌龟 | https://www.youtube.com/watch?v=FPgvMrguuPs | +| S24 | 厨房窗户开关动作 | https://ai2-public-datasets.s3-us-west-2.amazonaws.com/charades/Charades_v1_480.zip | +| S25 | 逆光窗户动作与携包经过 | https://ai2-public-datasets.s3-us-west-2.amazonaws.com/charades/Charades_v1_480.zip | +| S26 | 收拾衣物与篮子 | https://ai2-public-datasets.s3-us-west-2.amazonaws.com/charades/Charades_v1_480.zip | +| S27 | 厨房扫地_局部视野 | https://ai2-public-datasets.s3-us-west-2.amazonaws.com/charades/Charades_v1_480.zip | +| S28 | 门边手部小物体_钥匙可观察性 | https://www.youtube.com/watch?v=jNsO1K0mRwI | +| S29 | 狗打开柜门并拉扯垃圾袋 | https://www.youtube.com/watch?v=-82STtPbfEc | +| S30 | 人员拿包裹时身体遮挡 | https://www.youtube.com/watch?v=Xl-R3YCQRkY | +| S31 | 离家后短暂返回门口 | https://www.youtube.com/watch?v=WRnhem3hsxc | +| S32 | 清理桌面并擦拭_表演采集 | https://ai2-public-datasets.s3-us-west-2.amazonaws.com/charades/Charades_v1_480.zip | +| S33 | 固定机位车库清扫 | https://ai2-public-datasets.s3-us-west-2.amazonaws.com/charades/Charades_v1_480.zip | \ No newline at end of file diff --git a/README.md b/README.md index 05cdf98bf5e5099e3534deb3d20f739c92ffeb0e..afc7b52054006ef88f2c08a0fc1c278cb4081fee 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,49 @@ --- -title: OneAlign (Visual Quality/Aesthetic Scorer) -emoji: ⚖️ +title: Home Pulse +emoji: 🏡 colorFrom: green -colorTo: red +colorTo: yellow sdk: gradio -sdk_version: 4.12.0 +sdk_version: 6.30.0 +python_version: 3.12 app_file: app.py -pinned: true -license: mit -python_version: 3.10.14 +pinned: false +short_description: 用一句话设置家庭关注,确认对象,再交给视觉 AI 观察。 +tags: + - zerogpu + - computer-vision + - smart-home +models: + - mohit67890/imajev-4b + - Qwen/Qwen3.5-4B --- -arxiv.org/abs/2312.17090 +# Home Pulse -Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference \ No newline at end of file +家的消息,刚刚好。 + +**说明需求 → 看图确认对象与范围 → 澄清触发条件 → jev 试观察 → 启用 → 记忆复用。** + +This Space keeps the custom React interface and deterministic Node.js contract engine on free CPU hardware. Kimi handles user intent and visual grounding; visual decisions use the documented API of [the author's imajev Space](https://huggingface.co/spaces/mohit67890/imajev), running on HF ZeroGPU. The browser calls Gradio and the gateway forwards the visitor's `x-ip-token` to the model Space, following HF's cross-Space quota protocol. A short-lived authenticated loopback bridge connects visual responses to the rule engine. + +## Run and configure + +- `ANKER_KIMI_API_KEY`: server-side Space Secret for the competition Kimi API. +- Web hardware: **CPU Basic**. Visual backend: shared **ZeroGPU**. No paid hardware is requested. +- Open the direct `.hf.space` address to use the complete app on desktop or mobile browsers. +- Each browser has its own random workspace credential. Its memories, uploads, contracts and metrics are isolated from other visitors. Clearing browser storage also removes that browser's workspace credential. +- Free GPU allocation may queue and is subject to Hugging Face's visitor quota. Continuous observation runs while the observation page is open. +- Application data lives on the Space's temporary disk. Export important records before a rebuild; free Space storage is not a durable database. +- Task setup uses Kimi; images used for visual execution go to the HF Space. Secrets, local personal memories and local execution logs are excluded from the repository. + +## Models and attribution + +- [Imajev](https://github.com/mohit67890/imajev), by Mohit Garg, Apache-2.0. Only the required unmodified inference source is included under `upstream/`; its license is retained. +- [mohit67890/imajev-4b](https://huggingface.co/mohit67890/imajev-4b), adapter revision `f8d8234cebc6c99065c07731e59716dc0a6e27ab`. +- [Qwen/Qwen3.5-4B](https://huggingface.co/Qwen/Qwen3.5-4B), revision `851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a`, Apache-2.0. +- The shared model service manages its own model revision; requests enable its calibration and resize images to 640 pixels. It can update or be temporarily unavailable. Local NF4 results are not a claim about this hosted runtime. +- `app_zerogpu.py` and `requirements-zerogpu.txt` retain the separate own-GPU deployment option. That variant downloads the pinned revisions above from HF and uses BF16. It requires an account with ZeroGPU hosting access. +- Original model files are not modified or republished. +- Sample video source attribution is preserved in `media-library/说明与索引/完整素材索引.json` and `MEDIA-SOURCES.md`. + +The app provides image/video observation, bounded rule execution, on-page notifications, memories and operational metrics. Hardware camera events and phone push notifications are not connected. diff --git a/app.py b/app.py index 460a2cf7113bfd2c350255b3983ff12008802a49..5e11d9cfe61737c29d87d7f3ac285c338591f361 100644 --- a/app.py +++ b/app.py @@ -1,95 +1,136 @@ -import gradio as gr - -import argparse -import datetime -import json -import os -import time - -import gradio as gr -import requests -from PIL import Image - -from q_align.model.builder import load_pretrained_model - -from q_align.conversation import (default_conversation, conv_templates, - SeparatorStyle) -from q_align.constants import LOGDIR -from q_align.utils import (build_logger, server_error_msg, - violates_moderation, moderation_msg) - -from q_align.evaluate.scorer import QAlignScorer, QAlignAestheticScorer, QAlignVideoScorer - -import gradio as gr - -def load_video(video_file): - from decord import VideoReader - vr = VideoReader(video_file) - - # Get video frame rate - fps = vr.get_avg_fps() - - # Calculate frame indices for 1fps - frame_indices = [int(fps * i) for i in range(int(len(vr) / fps))] - frames = vr.get_batch(frame_indices).asnumpy() - return [Image.fromarray(frames[i]) for i in range(int(len(vr) / fps))] - - -pretrained="q-future/one-align" -device="cuda:0" -tokenizer, model, image_processor, _ = load_pretrained_model(pretrained, None, "mplug_owl2", device=device) - -iqa_scorer = QAlignScorer(tokenizer=tokenizer, model=model, image_processor=image_processor) -iaa_scorer = QAlignAestheticScorer(tokenizer=tokenizer, model=model, image_processor=image_processor) -vqa_scorer = QAlignVideoScorer(tokenizer=tokenizer, model=model, image_processor=image_processor) - -scorers = {"Image Aesthetics (IAA)": iaa_scorer, "Image Quality (IQA)": iqa_scorer, "Video Quality (VQA)": vqa_scorer} - -LEVELS = ["excellent (5)", "good (4)", "fair (3)", "poor (2)", "bad (1)"] -scores = [5,4,3,2,1] -def image_classifier(input_img, input_vid, scorer_type): - if scorer_type is None: - scorer_type = "Image Quality (IQA)" - this_scorer = scorers[scorer_type] - if input_vid is not None: - input_ = load_video(input_vid) - elif input_img is not None: - input_ = [input_img] - if "Video" in scorer_type: - input_ = [input_] - probs = this_scorer(input_).mean(0).tolist() - prob_dict = {LEVEL: prob for LEVEL, prob in zip(LEVELS, probs)} - score = sum([prob * score for score, prob in zip(scores, probs)]) - return prob_dict, score - -title_markdown = (""" - -
-Playground UI not built yet — the API is at POST /v1/systemone.