Day 28 - March 07, 2026
Parent: Week 25 - Daily Log | Nav Order: 28
Summary
Implemented the Legend gallery child app, fixed Gradio file-serving and rendering issues, added docs and tests, and enabled click-to-detail for dataset images.
Files
- Added:
apps/legend_gallery.py-LegendGalleryApp(BaseApp)(gallery, filters, click-to-details) - Added:
docs/legend_app.md- short user/developer guide - Modified:
app.py- whitelisted dataset paths for Gradio; registered static paths - Modified:
config.yaml- registeredlegend_galleryunderapps
Key Implementation Notes
- Data sources: labels from
vishal.csv(viasettings.storage.get_labels_dir()), images fromsettings.storage.get_faces_dir()(e.g.{Photo_No}.png). - R_ values (floats) bucketed into levels 0–3; UI supports
Alllevel. - Gallery is capped to 30 items (
MAX_GALLERY_ITEMS) for responsiveness. - Click behavior: selecting an item shows full image + metadata (photo id, R_ values, demographics) in the side panel.
- No absolute paths - all resolution uses platform
settingsAPIs.
Tests Performed
- CSV sanity:
vishal.csvloads (2,864 rows). - Instantiation test:
.venv\\Scripts\\python.exe -c "from apps.legend_gallery import LegendGalleryApp; inst=LegendGalleryApp('legend_gallery'); print(inst.faces_path, inst.csv_path.exists())"
- Functional filter test (programmatic):
items, status = inst.load_gallery('R_1','All','All','All')- returns 30 items and a correct status message. - Verified no import/runtime errors after edits.
Issues & Fixes
- Gradio InvalidPathError when serving files outside CWD.
- Fix: added
launch_kwargs['allowed_paths']withsettings.storage.get_faces_dir()inapp.pyand calledgr.set_static_paths([str(settings.storage.repos_dir)])increate_main_interface().
- Fix: added
- Duplicate-block render error (“A block with id … already rendered”).
- Fix: moved detail components into the main layout (side column) and update them via
gallery.select()instead of rendering twice.
- Fix: moved detail components into the main layout (side column) and update them via
Behavior Changes
- The app can serve images from the dataset directory (whitelisted for Gradio).
- Clicking a gallery image displays detailed metadata from
vishal.csv. legend_galleryappears as an app tab (registered inconfig.yaml).
Commands
Start the platform (development):
uv run gradio app.py
Quick import/test:
.venv\\Scripts\\python.exe -c "from apps.legend_gallery import LegendGalleryApp; inst=LegendGalleryApp('legend_gallery'); print(inst.faces_path, inst.csv_path.exists())"
Recommendations & Next Steps
- Make
vishal.csvfilename and image extension configurable viaconfig.yaml. - Add an assets mode (pre-built
assets/legend/R_*/) for Spaces-friendly deployment. - Add unit tests for
load_galleryand the click handler. - Implement Level 2: side-by-side comparison view and deeper metadata panels.
Progress: Level 1 architecture complete; model integration (float→level mapping) still in validation.
Detailed Notes
Core Architectural Finalization (Level 1)
We transitioned the project from a conceptual design to a functional, modular Child App within the Gradio-based ecosystem. Key points: - Dynamic Module Integration: Added `LegendGalleryApp` as a `BaseApp` subclass so the main `app.py` discovers and renders it as a first-class tab. - Optimized Data Engine: Implemented a lazy-loading cache for `vishal.csv` (`_get_df`) to avoid redundant disk I/O across UI interactions. - Normalized Severity Mapping: Introduced `LEVEL_RANGES` to bucket continuous R\_ floats into Levels 0–3 for clinical-readability.
Strategic "Loophole" Remediation
We identified and patched several stability and environment gaps: - Memory & Performance: Enforced `MAX_GALLERY_ITEMS = 30` to prevent browser overload when rendering many high-resolution faces. - Hot-reload stability: Hardened `discover_apps` in `app.py` to handle class reloads during development safely. - Environment parity: Detect whether running on Hugging Face Spaces vs local dev to adjust static paths and disable hot-reloads where appropriate.
Data & Labeling Alignment
- Region descriptions: Added human-readable `REGION_DESCRIPTIONS` for R_1..R_9 so clinicians see context when selecting regions. - Demographic filters: Filters for `I_1` (Gender) and `I_2` (Age Groups) are enabled and tested against CSV metadata. - Pathing: All file resolution uses `settings.storage` APIs—no hard-coded absolute paths.
Current Project Status
| Milestone | Status | Notes |
|---|---|---|
| Level 1 Architecture | ✅ COMPLETE | Class-based gallery, filtering, click-to-details implemented |
| Data Sync Logic | ✅ STABLE | CSV caching and face path resolution via HuggingFaceManager |
| Model Integration | 🛠️ IN PROGRESS | Validating float→level mapping and thresholds |
| Level 2 Design | 📋 PLANNED | Side-by-side comparison & metadata deep-dives |
Next Steps for Tomorrow
- Run a Level 1 smoke test across the full dataset to validate image serving and filter combinations.
- Add configuration options for
vishal.csvfilename and image extension inconfig.yaml. - Begin Level 2 design: implement side-by-side comparison view and deeper metadata panels.
- Add unit tests for
load_galleryand the click handler; automate in CI if possible.
The Legend gallery is integrated and stable for Level 1 usage; the next focus is on formalizing model thresholds and Level 2 UX features.