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 - registered legend_gallery under apps

Key Implementation Notes

  • Data sources: labels from vishal.csv (via settings.storage.get_labels_dir()), images from settings.storage.get_faces_dir() (e.g. {Photo_No}.png).
  • R_ values (floats) bucketed into levels 0–3; UI supports All level.
  • 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 settings APIs.

Tests Performed

  • CSV sanity: vishal.csv loads (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'] with settings.storage.get_faces_dir() in app.py and called gr.set_static_paths([str(settings.storage.repos_dir)]) in create_main_interface().
  • 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.

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_gallery appears as an app tab (registered in config.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

  1. Make vishal.csv filename and image extension configurable via config.yaml.
  2. Add an assets mode (pre-built assets/legend/R_*/) for Spaces-friendly deployment.
  3. Add unit tests for load_gallery and the click handler.
  4. 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

  1. Run a Level 1 smoke test across the full dataset to validate image serving and filter combinations.
  2. Add configuration options for vishal.csv filename and image extension in config.yaml.
  3. Begin Level 2 design: implement side-by-side comparison view and deeper metadata panels.
  4. Add unit tests for load_gallery and 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.

This site uses Just the Docs, a documentation theme for Jekyll.