Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,11 @@ import rembg
|
|
| 6 |
import cv2
|
| 7 |
import uuid
|
| 8 |
uid=uuid.uuid4()
|
| 9 |
-
if not os.path.exists(f'{uid}-frames'): os.makedirs(f'{uid}')
|
| 10 |
-
if not os.path.exists(f'{uid}-rembg'): os.makedirs(f'{uid}')
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
load_js = """
|
| 13 |
|
|
@@ -31,12 +34,49 @@ def rem_cv(inp):
|
|
| 31 |
fgmask = cv2.morphologyEx(fgmask, cv2.MORPH_OPEN, kernel)
|
| 32 |
yield (fgmask)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
def load_video(vid):
|
| 35 |
new_video_in = str(vid)
|
| 36 |
capture = cv2.VideoCapture(new_video_in)
|
| 37 |
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 38 |
tmp_frame='1'
|
| 39 |
capture.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
return frame_count
|
| 41 |
|
| 42 |
|
|
|
|
| 6 |
import cv2
|
| 7 |
import uuid
|
| 8 |
uid=uuid.uuid4()
|
| 9 |
+
if not os.path.exists(f'{uid}-frames'): os.makedirs(f'{uid}-frames')
|
| 10 |
+
if not os.path.exists(f'{uid}-rembg'): os.makedirs(f'{uid}-rembg')
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
|
| 14 |
|
| 15 |
load_js = """
|
| 16 |
|
|
|
|
| 34 |
fgmask = cv2.morphologyEx(fgmask, cv2.MORPH_OPEN, kernel)
|
| 35 |
yield (fgmask)
|
| 36 |
|
| 37 |
+
def get_rate(vid_in):
|
| 38 |
+
cap = cv2.VideoCapture(vid_in)
|
| 39 |
+
|
| 40 |
+
while(cap.isOpened()):
|
| 41 |
+
|
| 42 |
+
# Capture frame-by-frame
|
| 43 |
+
|
| 44 |
+
ret, frame = cap.read()
|
| 45 |
+
|
| 46 |
+
# if video finished or no Video Input
|
| 47 |
+
if not ret:
|
| 48 |
+
break
|
| 49 |
+
|
| 50 |
+
# Our operations on the frame come here
|
| 51 |
+
gray = frame
|
| 52 |
+
|
| 53 |
+
# resizing the frame size according to our need
|
| 54 |
+
gray = cv2.resize(gray, (500, 300))
|
| 55 |
+
|
| 56 |
+
# font which we will be using to display FPS
|
| 57 |
+
font = cv2.FONT_HERSHEY_SIMPLEX
|
| 58 |
+
# time when we finish processing for this frame
|
| 59 |
+
new_frame_time = time.time()
|
| 60 |
+
|
| 61 |
+
# Calculating the fps
|
| 62 |
+
|
| 63 |
+
# fps will be number of frame processed in given time frame
|
| 64 |
+
# since their will be most of time error of 0.001 second
|
| 65 |
+
# we will be subtracting it to get more accurate result
|
| 66 |
+
fps = 1/(new_frame_time-prev_frame_time)
|
| 67 |
+
prev_frame_time = new_frame_time
|
| 68 |
+
|
| 69 |
+
|
| 70 |
def load_video(vid):
|
| 71 |
new_video_in = str(vid)
|
| 72 |
capture = cv2.VideoCapture(new_video_in)
|
| 73 |
frame_count = int(capture.get(cv2.CAP_PROP_FRAME_COUNT))
|
| 74 |
tmp_frame='1'
|
| 75 |
capture.release()
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
return frame_count
|
| 81 |
|
| 82 |
|