owinymarvin commited on
Commit
bc79b5b
·
1 Parent(s): 6f472e5

latest changes

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -12,13 +12,13 @@ from collections import deque
12
  HF_MODEL_REPO_ID = "owinymarvin/timesformer-crime-detection"
13
 
14
  # These must match the values used during your training
15
- NUM_FRAMES = 8 # Changed back to 8 as that was your original training setup for this model
16
  TARGET_IMAGE_HEIGHT = 224
17
  TARGET_IMAGE_WIDTH = 224
18
 
19
  # --- Prediction Timing ---
20
  # How long to record (in seconds) before making a prediction
21
- RECORDING_DURATION_SECONDS = 3.0
22
  # How often the model should predict (after the recording duration)
23
  # Setting this to a very high number (like 9999) means it essentially predicts only once
24
  # after the recording is done until reset. Or you can leave it at 1.0 if you want it to trigger often.
@@ -105,6 +105,7 @@ def reset_app_state():
105
  recording_start_time = None
106
  last_prediction_time = time.time()
107
  print("App state reset.")
 
108
  return "Ready to record...", "Ready for new prediction."
109
 
110
  # --- Gradio Interface ---
@@ -115,6 +116,7 @@ with gr.Blocks() as demo:
115
  This demo uses a finetuned TimesFormer model ({HF_MODEL_REPO_ID}) to predict crime actions from a live webcam feed.
116
  It records **{RECORDING_DURATION_SECONDS} seconds** of video, then automatically triggers a prediction.
117
  The model processes **{NUM_FRAMES} frames** per prediction.
 
118
  Please allow webcam access.
119
  """
120
  )
@@ -129,7 +131,7 @@ with gr.Blocks() as demo:
129
  status_output = gr.Textbox(label="Status", value="Ready to record...")
130
 
131
  # Reset Button
132
- reset_button = gr.Button("Reset / Start New Recording Cycle")
133
 
134
  with gr.Column():
135
  prediction_output = gr.Textbox(label="Prediction Result", value="Recording will start automatically.")
 
12
  HF_MODEL_REPO_ID = "owinymarvin/timesformer-crime-detection"
13
 
14
  # These must match the values used during your training
15
+ NUM_FRAMES = 8 # Still using 8 frames, as that was your original training setup
16
  TARGET_IMAGE_HEIGHT = 224
17
  TARGET_IMAGE_WIDTH = 224
18
 
19
  # --- Prediction Timing ---
20
  # How long to record (in seconds) before making a prediction
21
+ RECORDING_DURATION_SECONDS = 10.0 # CHANGED: Now records for 10 seconds
22
  # How often the model should predict (after the recording duration)
23
  # Setting this to a very high number (like 9999) means it essentially predicts only once
24
  # after the recording is done until reset. Or you can leave it at 1.0 if you want it to trigger often.
 
105
  recording_start_time = None
106
  last_prediction_time = time.time()
107
  print("App state reset.")
108
+ # Return initial messages for the UI
109
  return "Ready to record...", "Ready for new prediction."
110
 
111
  # --- Gradio Interface ---
 
116
  This demo uses a finetuned TimesFormer model ({HF_MODEL_REPO_ID}) to predict crime actions from a live webcam feed.
117
  It records **{RECORDING_DURATION_SECONDS} seconds** of video, then automatically triggers a prediction.
118
  The model processes **{NUM_FRAMES} frames** per prediction.
119
+ Click 'Reset' to start a new video recording.
120
  Please allow webcam access.
121
  """
122
  )
 
131
  status_output = gr.Textbox(label="Status", value="Ready to record...")
132
 
133
  # Reset Button
134
+ reset_button = gr.Button("Reset / Start New Video")
135
 
136
  with gr.Column():
137
  prediction_output = gr.Textbox(label="Prediction Result", value="Recording will start automatically.")