Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
import spaces
|
| 2 |
import gradio as gr
|
| 3 |
import cv2
|
| 4 |
import numpy as np
|
|
@@ -7,8 +6,6 @@ import torch
|
|
| 7 |
from PIL import Image
|
| 8 |
import torch.nn.functional as F
|
| 9 |
from facenet_pytorch import MTCNN
|
| 10 |
-
import tempfile
|
| 11 |
-
import os
|
| 12 |
import matplotlib.pyplot as plt
|
| 13 |
|
| 14 |
# Global variables
|
|
@@ -21,7 +18,6 @@ current_model_name = "ViT-B/32"
|
|
| 21 |
# Initialize MTCNN for face detection
|
| 22 |
mtcnn = MTCNN(keep_all=False, device=device, thresholds=[0.95, 0.95, 0.95], min_face_size=80)
|
| 23 |
|
| 24 |
-
@spaces.GPU(duration=250)
|
| 25 |
def process_frame(frame, selected_model):
|
| 26 |
global model, preprocess, current_model_name
|
| 27 |
|
|
@@ -105,7 +101,6 @@ def process_frame(frame, selected_model):
|
|
| 105 |
print(f"An error occurred: {str(e)}")
|
| 106 |
return frame
|
| 107 |
|
| 108 |
-
@spaces.GPU(duration=250)
|
| 109 |
def process_video(input_video, selected_model, frame_index):
|
| 110 |
try:
|
| 111 |
cap = cv2.VideoCapture(input_video)
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import cv2
|
| 3 |
import numpy as np
|
|
|
|
| 6 |
from PIL import Image
|
| 7 |
import torch.nn.functional as F
|
| 8 |
from facenet_pytorch import MTCNN
|
|
|
|
|
|
|
| 9 |
import matplotlib.pyplot as plt
|
| 10 |
|
| 11 |
# Global variables
|
|
|
|
| 18 |
# Initialize MTCNN for face detection
|
| 19 |
mtcnn = MTCNN(keep_all=False, device=device, thresholds=[0.95, 0.95, 0.95], min_face_size=80)
|
| 20 |
|
|
|
|
| 21 |
def process_frame(frame, selected_model):
|
| 22 |
global model, preprocess, current_model_name
|
| 23 |
|
|
|
|
| 101 |
print(f"An error occurred: {str(e)}")
|
| 102 |
return frame
|
| 103 |
|
|
|
|
| 104 |
def process_video(input_video, selected_model, frame_index):
|
| 105 |
try:
|
| 106 |
cap = cv2.VideoCapture(input_video)
|