Skip to content

fix: resolve ZeroDivisionError in mvp.py and enable dynamic video loading#16

Open
Kunal-Somani wants to merge 1 commit into
ruxailab:mainfrom
Kunal-Somani:fix-mvp-zero-division
Open

fix: resolve ZeroDivisionError in mvp.py and enable dynamic video loading#16
Kunal-Somani wants to merge 1 commit into
ruxailab:mainfrom
Kunal-Somani:fix-mvp-zero-division

Conversation

@Kunal-Somani

@Kunal-Somani Kunal-Somani commented Mar 9, 2026

Copy link
Copy Markdown

Resolves #13

Objective

Resolves the ZeroDivisionError in mvp.py identified in #13 and allows for dynamic video path loading.

Technical Changes

  1. Updated cv2.VideoCapture() in main() to utilize the passed video_path argument instead of a hardcoded fv.mp4 string.
  2. Implemented an early-exit guard clause in getPercentages() to safely return an empty dictionary if the predictions array is empty. This prevents a fatal crash when processing edge cases (e.g., corrupted files or frames with no detectable faces).

Validation

Verified locally by executing mvp.py against a nonexistent/empty video file. The application successfully logs No predictions generated. Returning empty percentages. and exits cleanly instead of throwing a Python traceback.

Terminal Proof:

(venv) kunal@kunal-OMEN-by-HP-Gaming-Laptop-16-wf1xxx:~/.../facial-sentiment-analysis-api$ python3 mvp.py dummy_nonexistent_video.mp4
# ... [TensorFlow initialization logs omitted for brevity] ...
[]
No predictions generated. Returning empty percentages.

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.

Fix: Resolve MVP pipeline ZeroDivisionError & optimize hardware utilization via TensorFlow fallback

1 participant