yunusajib commited on
Commit
4c293c6
·
verified ·
1 Parent(s): 990dede
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -131,24 +131,19 @@ class EmotionDetector:
131
  def create_interface():
132
  detector = EmotionDetector()
133
 
134
- def process(video_file, sample_rate):
135
- if video_file is None:
136
- return None, "Please upload a video."
137
 
138
- try:
139
- # Read and save to a temporary file
140
- with tempfile.NamedTemporaryFile(delete=False, suffix=".mp4") as tmp:
141
- tmp.write(video_file.read())
142
- tmp_path = tmp.name
143
 
144
- return detector.detect_emotions_video(tmp_path, sample_rate)
145
- except Exception as e:
146
- return None, f"Error processing video: {str(e)}"
147
 
148
  return gr.Interface(
149
  fn=process,
150
  inputs=[
151
- gr.Video(label="Upload Video"),
152
  gr.Slider(minimum=1, maximum=60, step=1, value=30, label="Sample Rate (Frames)")
153
  ],
154
  outputs=[
@@ -159,5 +154,6 @@ def create_interface():
159
  description="Upload a video to analyze emotions over time."
160
  )
161
 
 
162
  if __name__ == "__main__":
163
  create_interface().launch()
 
131
  def create_interface():
132
  detector = EmotionDetector()
133
 
134
+ def create_interface():
135
+ detector = EmotionDetector()
 
136
 
137
+ def process(video_path, sample_rate):
138
+ if video_path is None or not os.path.exists(video_path):
139
+ return None, "Invalid video path or no video uploaded."
 
 
140
 
141
+ return detector.detect_emotions_video(video_path, sample_rate)
 
 
142
 
143
  return gr.Interface(
144
  fn=process,
145
  inputs=[
146
+ gr.Video(label="Upload Video"), # Removed type="file"
147
  gr.Slider(minimum=1, maximum=60, step=1, value=30, label="Sample Rate (Frames)")
148
  ],
149
  outputs=[
 
154
  description="Upload a video to analyze emotions over time."
155
  )
156
 
157
+
158
  if __name__ == "__main__":
159
  create_interface().launch()