Running and building on Mnemo
Mnemo turns first-person video into a short, time-stamped text diary of what the wearer did, then answers questions from that diary alone. This page covers installation, every command and setting, the architecture, and how to reproduce the reported numbers. The source is on GitHub.
Overview
There are two ways to use Mnemo:
- Diary mode (GPU). Any action, any object. HOI-TCN decides which 4-second windows are worth describing. Qwen3-VL-4B describes them in fixed lines, an object-state memory adds opens and closes, and questions are answered from the diary with times. This is the mode behind the results on the home page.
- Tracker mode (CPU). The original pick-up / put-down tracker for a few personal objects (keys, wallet, phone, pill bottle). It remembers the place where each object was put down and learns daily habits.
In the ENGRAM paper (in preparation), the method is called Egocentric Neural Grounded Retrieval of Actions and Moments, and the diary is the reference diary.
Installation
git clone https://github.com/imlikhiths/MNemo.git cd MNemo python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cpu python -m pytest
- Tested on Linux with Python 3.14. The test suite has 87 tests on synthetic data, so no dataset is needed.
- The trained trigger ships in the repository (
models/hoi_tcn.pt, 1 MB). - The MediaPipe hand model and YOLOv8n download automatically the first time they are used.
- For diary mode, also install
pip install "transformers>=4.57" accelerate.
Linux audio note. On some systems, MediaPipe's import of sounddevice crashes
through PortAudio. Mnemo uses no audio, so modules/hand_detector.py replaces that module with an
empty stub.
Quick start
Diary mode
python mnemo.py log kitchen.mp4 --start "2026-10-17 08:30" --trigger python mnemo.py activities python mnemo.py qa "did I close the fridge?" --llm
--triggerlets HOI-TCN choose the windows the VLM describes. Without it, every window is described.- Without
--llm,qalists the matching diary rows and needs no GPU. - Qwen3-VL-4B needs a 16 GB GPU such as a T4.
Qwen/Qwen3-VL-2B-Instructis smaller and faster.
Tracker mode
python mnemo.py run recording.mp4 --mode model --show python mnemo.py ask "where is my wallet?" python mnemo.py simulate --days 14 python mnemo.py habits --simulated
run 0 --show uses a live camera. The habit demo runs on simulated history. Say so whenever
you present it.
Running on Kaggle
The free Kaggle T4 is enough for everything. Package the code with python -m tools.make_colab_zip,
upload mnemo_code.zip as a Kaggle dataset, and open a notebook with GPU T4 and internet turned on:
| Notebook | What it does |
|---|---|
colab/mnemo_live_demo.ipynb | Any first-person video → diary → type your own questions. The video should be 2–3 minutes; processing takes about 1.5× its length. |
colab/mnemo_kaggle.ipynb | The full benchmark: trigger vs. fixed rate, state memory, question answering, and the whole-morning test. |
colab/mnemo_ego4d.ipynb | The Ego4D Natural Language Queries test. Needs an approved Ego4D licence; the AWS keys go in Kaggle Secrets. |
colab/mnemo_vlm.ipynb | Diary mode on Google Colab. |
colab/mnemo_train.ipynb | Trains HOI-TCN on public datasets. |
Commands
Every command is a subcommand of python mnemo.py. The global option --db PATH
selects the database (default outputs/mnemo.db).
| Command | Main options | What it does |
|---|---|---|
log SOURCE | --start --trigger --threshold --model --max-seconds --checkpoint | Stage 1: video → diary, using the vision-language model |
qa QUESTION | --llm --model --now | Stage 2: answer from the diary, or list matching rows |
activities | --limit | Print the diary |
run SOURCE | --mode rules|model --show --start --objects --no-landmarks | Tracker mode on a video file or a camera index |
ask QUESTION | --now --simulated | "Where is X?" from tracker events |
events | --limit --simulated | List tracker events |
enroll | --dir --check --check-only | Build the landmark index from short clips of each place |
habits | --now --simulated | Learned routines and missed-routine alerts |
simulate | --days --end --no-miss | Write simulated history to a separate database |
Configuration
Every setting lives in config.py. Values marked TUNE there are starting points to
measure on your own footage. The main ones:
| Setting | Default | Meaning |
|---|---|---|
VLM_MODEL | Qwen/Qwen3-VL-4B-Instruct | The model that describes windows and answers questions |
VLM_WINDOW_S | 4.0 | Seconds of video per description |
VLM_FRAMES / VLM_FRAME_W | 8 / 448 | Frames per window, and their width in pixels |
VLM_TRACK_STATES | True | Object-state memory: open/closed, on/off, re-checks |
VLM_MAX_ACTIONS | 8 | Maximum actions per window (stops repetition loops) |
STATE_CHECK_MAX_AGE_S | 600 | How long an open object keeps being re-checked |
QA_MAX_LOG_LINES | 60 | Diary rows given to the model when it answers |
GATE_THRESHOLD | 0.6 | Trigger threshold τ on the window score |
GATE_HEARTBEAT_S | 20.0 | Describe at least one window this often |
PROCESS_FPS / PROCESS_WIDTH | 10 / 640 | Frame rate and width for perception |
OBJECT_BACKEND | auto | Fine-tuned YOLO if present, else YOLO-World, else COCO |
LANDMARK_MIN_SIM | 0.80 | Below this similarity, a place is "unknown" (tracker mode) |
Architecture
The always-on lane (perception and HOI-TCN) runs on every frame on the CPU. The on-demand lane (the VLM) runs only for windows the trigger selects, plus a heartbeat every 20 s. Frames are held in RAM only while their window is processed. See the methodology for the full picture.
| Part | Code |
|---|---|
| Command line, settings | mnemo.py, config.py |
| Video source, RAM-only buffer | modules/video_source.py |
| Perception: hands, objects, camera motion | modules/hand_detector.py, object_detector.py, ego_motion.py, perception.py |
| 105-number feature per frame | modules/features.py |
| HOI-TCN model and training | model/architecture.py, train.py, evaluate.py, metrics.py |
| Interaction trigger | modules/hoi_gate.py |
| Stage 1: VLM describer and state memory | modules/vlm_logger.py |
| Diary and event store (SQLite) | modules/storage.py |
| Stage 2: grounded answers, moment search | query/llm_qa.py, query/locate.py |
| Tracker mode: rules, places, habits | modules/interaction.py, landmarks.py, habits.py, query/query_engine.py |
| Experiments | evaluation/ |
| Dataset fetchers, labelling, demo video | tools/ |
Diary format
The diary is one SQLite table, activities, with one row per action. A 2.4-hour morning produced
636 rows in a 240 kB file.
| Column | Meaning |
|---|---|
ts_start, ts_end | Start and end of the window, in local time |
verb | The action, from a fixed list of everyday verbs. Empty when nothing was done with the hands (place only). |
object | The object acted on |
place | Where the wearer was |
where_ | Where the object is or ended up |
raw | The model's full answer, kept for checking |
source | Which video produced the row; rows derived from a state change are marked as such |
For each window, the VLM fills in fixed lines, which are then parsed into rows:
PLACE: kitchen counter STATE: fridge = open DID: put | milk | fridge
The small model: HOI-TCN
- What it is. A causal temporal convolutional network. It gives each frame a probability of pick-up, put-down or none.
- Input. 105 numbers per frame: 45 per hand (presence, wrist position, landmarks relative to the wrist, velocity relative to the background), 13 for the tracked object nearest a hand, and 2 for camera motion.
- Layers. One encoder per modality (64, 32 and 8 units), a projection to 96 channels, and four residual blocks of causal convolutions (kernel 3, dilation 1, 2, 4, 8). The receptive field is 61 frames, about 6 s.
- Size. 240,252 parameters.
- Window score. The score is the maximum of 1 − P(none) over the window. A window is sent on when its score is at least τ, or when 20 s have passed since the last call.
The convolutions only look at past frames, so the same network runs live, frame by frame. A test checks that streaming output equals full-sequence output.
Training
- Data. EPIC-KITCHENS-100 pieces rich in take and put actions, split by person: 68 pieces from 22 people for training, 16 from 5 others for validation and 16 from another 5 for testing.
- Setup. AdamW (lr 10⁻³, weight decay 10⁻³, cosine schedule), batches of 64. The loss is class-weighted cross-entropy plus a holding head with weight 0.5. Whole modalities are dropped at random (p = 0.1). Early stopping uses validation event F1.
- Charades-Ego was tried, but it lowered put-down accuracy, so the final model uses EPIC-KITCHENS-100 only.
python -m model.train --features data/features/epic --batch-size 64 --out models/hoi_tcn.pt python -m model.evaluate --checkpoint models/hoi_tcn.pt --features data/features/epic --split test
Test results on held-out people: F1 0.529, precision 0.446, recall 0.652. The ablation table is on the results section of the home page.
Reproducing the results
- Run
colab/mnemo_kaggle.ipynbon a Kaggle T4. The VLM runs once over every window, and each system (every window, trigger at each threshold, every N-th window, with and without states) is replayed from that single pass. All systems are therefore scored on the same model outputs. - Download
mnemo_results.zipand unzip it. - Draw the figures:
python -m evaluation.make_figures --results <unzipped folder> --out docs/figures
- Test set. 20 random one-minute clips from EPIC-KITCHENS-100 participants P02, P06, P08, P14 and P26. None of them were used in training.
- Validation people. P04, P21, P22, P27 and P31.
- The threshold. τ = 0.6 was read off the test curve, which is why every threshold is reported.
| Experiment | Code |
|---|---|
| Benchmark: one VLM pass, replayed for every system | evaluation/benchmark.py |
| Diary accuracy against EPIC ground truth | evaluation/log_accuracy.py |
| Yes/no questions, incl. the direct-VLM baseline | evaluation/qa_benchmark.py |
| Whole-morning questions | evaluation/long_qa.py |
| Trigger settings on validation people | evaluation/tune_gate.py |
| Ego4D Natural Language Queries | evaluation/ego4d_nlq.py, tools/fetch_ego4d.py |
Using your own footage
Tracker mode can be tuned for one home. You can mount the camera, fine-tune YOLO on your own objects, enroll places from short clips, then label and evaluate your own videos. The step-by-step guide is docs/own_footage.md.
Privacy
- Frames are kept only in a RAM buffer, and only while their window is processed. Nothing visual is
written to disk.
tests/test_privacy_and_pipeline.pyruns the real pipeline with every image-writing function blocked, and fails if any image or video file appears. - The diary is plain text in a local SQLite file, and the whole system can run on one machine.
- The text can still be sensitive. A real deployment needs encryption and user-controlled deletion. The guarantee covers stored data, not someone inspecting the running machine's memory.
Limitations
- Kitchens and head-mounted cameras. All quantitative results come from EPIC-KITCHENS-100, which was filmed with head-mounted cameras. Mnemo is meant to be worn on the chest.
- Strict scoring. Recall of 26–31% reflects strict scoring, which requires the exact verb and noun class. Read the numbers as comparisons between systems that share the same VLM outputs.
- Small morning test. It joins separate clips and has 38 questions.
- Narrow trigger. HOI-TCN knows only pick-up and put-down. Actions like stirring or wiping are caught mainly by the heartbeat.
- Not a medical device. There has been no user study. Mnemo is a research prototype.
Data and licences
The repository contains no videos and no dataset files.
| Component | Licence | Used for |
|---|---|---|
| Mnemo code | MIT | — |
| EPIC-KITCHENS-100 | CC BY-NC 4.0 | Training HOI-TCN, all results, the clips on this site |
| Ego4D | Ego4D licence | NLQ test; clips must not be redistributed |
| MediaPipe Hand Landmarker | Apache-2.0 | Hand landmarks |
| Ultralytics YOLOv8 / YOLO-World | AGPL-3.0 | Object detection |
| Qwen3-VL-4B-Instruct | Apache-2.0 | Describing windows, answering questions |
| OpenCLIP | MIT | Place matching in tracker mode |
- The HOI-TCN weights were trained on EPIC-KITCHENS-100 only. Treat them as non-commercial too.
- Ultralytics is AGPL-3.0. If you distribute a product that includes it, its terms apply to that product.