dhairyashah commited on
Commit
0bfe8cd
·
1 Parent(s): 32f517b
Files changed (1) hide show
  1. app.py +4 -0
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from flask import Flask, request, jsonify
2
  import os
3
  from werkzeug.utils import secure_filename
@@ -35,6 +36,7 @@ model.eval()
35
  def allowed_file(filename):
36
  return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
37
 
 
38
  def process_frame(frame):
39
  face = mtcnn(frame)
40
  if face is None:
@@ -53,6 +55,7 @@ def process_frame(frame):
53
 
54
  return prediction, output.item()
55
 
 
56
  def analyze_video(video_path, sample_rate=30):
57
  cap = cv2.VideoCapture(video_path)
58
  frame_count = 0
@@ -92,6 +95,7 @@ def analyze_video(video_path, sample_rate=30):
92
  def home():
93
  return jsonify({'homepage': 'https://deepfake-checker.dhairyashah.dev'})
94
 
 
95
  @app.route('/analyze', methods=['POST'])
96
  def analyze_video_api():
97
  if 'video' not in request.files:
 
1
+ import spaces
2
  from flask import Flask, request, jsonify
3
  import os
4
  from werkzeug.utils import secure_filename
 
36
  def allowed_file(filename):
37
  return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
38
 
39
+ @spaces.GPU
40
  def process_frame(frame):
41
  face = mtcnn(frame)
42
  if face is None:
 
55
 
56
  return prediction, output.item()
57
 
58
+ @spaces.GPU
59
  def analyze_video(video_path, sample_rate=30):
60
  cap = cv2.VideoCapture(video_path)
61
  frame_count = 0
 
95
  def home():
96
  return jsonify({'homepage': 'https://deepfake-checker.dhairyashah.dev'})
97
 
98
+ @spaces.GPU
99
  @app.route('/analyze', methods=['POST'])
100
  def analyze_video_api():
101
  if 'video' not in request.files: