sdafd commited on
Commit
aa6550a
·
verified ·
1 Parent(s): 04704b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -191,23 +191,22 @@ def extract_frames(video_path, num_frames):
191
 
192
  # Gradio app logic
193
  def process_video(video, num_frames):
194
- print(video)
195
- video_path = os.path.join(tempfile.gettempdir(), video)
196
- with open(video_path, "wb") as f:
197
- f.write(video.read())
198
 
199
- frames = extract_frames(video_path, num_frames)
 
200
 
201
  nsfw_count = 0
202
  total_frames = len(frames)
203
 
 
204
  for frame_path in frames:
205
  if check_nsfw_final(frame_path):
206
  nsfw_count += 1
207
- os.remove(frame_path)
208
 
209
  return f"{nsfw_count} out of {total_frames} frames were NSFW."
210
 
 
211
  with gr.Blocks() as app:
212
  gr.Markdown("## NSFW Frame Detection in Video")
213
 
 
191
 
192
  # Gradio app logic
193
  def process_video(video, num_frames):
 
 
 
 
194
 
195
+ # Extract frames from the video
196
+ frames = extract_frames(video, num_frames)
197
 
198
  nsfw_count = 0
199
  total_frames = len(frames)
200
 
201
+ # Check each frame for NSFW content
202
  for frame_path in frames:
203
  if check_nsfw_final(frame_path):
204
  nsfw_count += 1
205
+ os.remove(frame_path) # Clean up temp frame files
206
 
207
  return f"{nsfw_count} out of {total_frames} frames were NSFW."
208
 
209
+
210
  with gr.Blocks() as app:
211
  gr.Markdown("## NSFW Frame Detection in Video")
212