Skip to content

fixes #560: add computational cost tab to GUI evaluator#561

Open
AdityaX18 wants to merge 1 commit intoJdeRobot:masterfrom
AdityaX18:issue_N_computational_cost_tab
Open

fixes #560: add computational cost tab to GUI evaluator#561
AdityaX18 wants to merge 1 commit intoJdeRobot:masterfrom
AdityaX18:issue_N_computational_cost_tab

Conversation

@AdityaX18
Copy link
Copy Markdown

@AdityaX18 AdityaX18 commented Apr 20, 2026

Summary

Fixes #560

Adds a Computational Cost tab to the Streamlit GUI that wraps TorchImageDetectionModel.get_computational_cost() for the currently loaded detection model. Closes the GUI ↔ CLI feature parity gap flagged in the discussion on #539.

Closes #XXX.

Changes

  • New tabs/computational_cost.py — standalone tab function following the *_tab() convention used by the other three tabs. No shared base (matches the existing codebase pattern).
  • Modified app.py — three edits:
    1. Import computational_cost_tab
    2. Extend st.tabs([...]) from 3 to 4 entries
    3. Extend the PAGES dict to stay in sync

How it works

  • Reuses the same sidebar-loaded model via st.session_state.detection_model (consistent with evaluator_tab and inference_tab).
  • Gates the expensive get_computational_cost() call behind st.button("Run Cost Analysis") so widget interactions (number inputs) don't retrigger 30+ forward passes on every keystroke.
  • Persists the resulting DataFrame in st.session_state.computational_cost_result so re-renders on widget changes reuse the cached result instead of recomputing.
  • Renders metrics using the same unit conventions as examples/torch_computational_cost.py (n_params / 1e6 for M, inference_time_s * 1000 for ms) — no new formatting invented.
  • Derived throughput (FPS = 1 / inference_time_s) added as an extra metric — not in the DataFrame, but useful for deployment decisions. Handles the zero-division edge case.
  • CSV export via st.download_button mirrors the CLI's results.to_csv(out_fname) behavior.

Testing

Manual, locally:

  • streamlit run app.py launches without errors.
  • All three pre-existing tabs still render correctly.
  • New tab shows a warning when no detection model is loaded.
  • After loading a torchvision detection model from the sidebar, the tab accepts custom image size + runs + warm-up and produces sensible numbers (params in M, size in MB, latency in ms, FPS derived correctly).
  • CSV download produces a file with the same 4-column schema the CLI produces.
  • Modifying the number inputs after a run does NOT retrigger the forward passes (button-gated, confirmed via terminal output).

Out of scope

  • No changes to get_computational_cost() itself. FLOPs / MACs reporting is proposed as a follow-up issue with a separate dependency discussion.
  • No segmentation / LiDAR changes. The GUI currently supports detection only per the README; extending to other tasks is a follow-up when GUI support is extended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add computational cost tab to GUI evaluator

1 participant