Spaces:
Running
Running
Ubuntu
commited on
Commit
•
e2259e8
1
Parent(s):
4e48206
- .ipynb_checkpoints/app-checkpoint.py +19 -8
- .ipynb_checkpoints/requirements-checkpoint.txt +2 -1
- app.py +19 -8
- requirements.txt +2 -1
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -4,13 +4,24 @@ import cv2
|
|
4 |
from encoded_video import EncodedVideo, write_video
|
5 |
import torch
|
6 |
import numpy as np
|
|
|
7 |
|
8 |
-
def video_identity(
|
9 |
-
vid = EncodedVideo.from_path(filepath)
|
10 |
-
clip = vid.get_clip(start_sec, start_sec + duration)
|
11 |
-
video_arr = torch.from_numpy(clip['video']).permute(3, 0, 1, 2)
|
12 |
-
write_video('out.mp4', video_arr, fps=60)
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
while (True):
|
15 |
|
16 |
success, frame = capture.read()
|
@@ -25,7 +36,7 @@ def video_identity(filepath):
|
|
25 |
img=cv2.imread('train/frame_0')
|
26 |
return img
|
27 |
demo = gr.Interface(video_identity,
|
28 |
-
gr.
|
29 |
-
gr.
|
30 |
cache_examples=True)
|
31 |
demo.launch(debug=True)
|
|
|
4 |
from encoded_video import EncodedVideo, write_video
|
5 |
import torch
|
6 |
import numpy as np
|
7 |
+
import gc
|
8 |
|
9 |
+
def video_identity(video):
|
10 |
+
# vid = EncodedVideo.from_path(filepath)
|
11 |
+
# clip = vid.get_clip(start_sec, start_sec + duration)
|
12 |
+
# video_arr = torch.from_numpy(clip['video']).permute(3, 0, 1, 2)
|
13 |
+
# write_video('out.mp4', video_arr, fps=60)
|
14 |
+
|
15 |
+
gc.collect()
|
16 |
+
output_video_path = "./output.mp4"
|
17 |
+
cap = cv2.VideoCapture(video)
|
18 |
+
fourcc = cv2.VideoWriter_fourcc(*"I420") # encoder
|
19 |
+
|
20 |
+
out = cv2.VideoWriter(output_video_path, fourcc, 30.0, (int(cap.get(3)), int(cap.get(4))))
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
capture = cv2.VideoCapture('output.mp4')
|
25 |
while (True):
|
26 |
|
27 |
success, frame = capture.read()
|
|
|
36 |
img=cv2.imread('train/frame_0')
|
37 |
return img
|
38 |
demo = gr.Interface(video_identity,
|
39 |
+
gr.Video(source='upload'),
|
40 |
+
gr.Image(),
|
41 |
cache_examples=True)
|
42 |
demo.launch(debug=True)
|
.ipynb_checkpoints/requirements-checkpoint.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
opencv-python
|
2 |
encoded-video
|
3 |
torch
|
4 |
-
numpy
|
|
|
|
1 |
opencv-python
|
2 |
encoded-video
|
3 |
torch
|
4 |
+
numpy
|
5 |
+
gc-python-utils
|
app.py
CHANGED
@@ -4,13 +4,24 @@ import cv2
|
|
4 |
from encoded_video import EncodedVideo, write_video
|
5 |
import torch
|
6 |
import numpy as np
|
|
|
7 |
|
8 |
-
def video_identity(
|
9 |
-
vid = EncodedVideo.from_path(filepath)
|
10 |
-
clip = vid.get_clip(start_sec, start_sec + duration)
|
11 |
-
video_arr = torch.from_numpy(clip['video']).permute(3, 0, 1, 2)
|
12 |
-
write_video('out.mp4', video_arr, fps=60)
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
while (True):
|
15 |
|
16 |
success, frame = capture.read()
|
@@ -25,7 +36,7 @@ def video_identity(filepath):
|
|
25 |
img=cv2.imread('train/frame_0')
|
26 |
return img
|
27 |
demo = gr.Interface(video_identity,
|
28 |
-
gr.
|
29 |
-
gr.
|
30 |
cache_examples=True)
|
31 |
demo.launch(debug=True)
|
|
|
4 |
from encoded_video import EncodedVideo, write_video
|
5 |
import torch
|
6 |
import numpy as np
|
7 |
+
import gc
|
8 |
|
9 |
+
def video_identity(video):
|
10 |
+
# vid = EncodedVideo.from_path(filepath)
|
11 |
+
# clip = vid.get_clip(start_sec, start_sec + duration)
|
12 |
+
# video_arr = torch.from_numpy(clip['video']).permute(3, 0, 1, 2)
|
13 |
+
# write_video('out.mp4', video_arr, fps=60)
|
14 |
+
|
15 |
+
gc.collect()
|
16 |
+
output_video_path = "./output.mp4"
|
17 |
+
cap = cv2.VideoCapture(video)
|
18 |
+
fourcc = cv2.VideoWriter_fourcc(*"I420") # encoder
|
19 |
+
|
20 |
+
out = cv2.VideoWriter(output_video_path, fourcc, 30.0, (int(cap.get(3)), int(cap.get(4))))
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
capture = cv2.VideoCapture('output.mp4')
|
25 |
while (True):
|
26 |
|
27 |
success, frame = capture.read()
|
|
|
36 |
img=cv2.imread('train/frame_0')
|
37 |
return img
|
38 |
demo = gr.Interface(video_identity,
|
39 |
+
gr.Video(source='upload'),
|
40 |
+
gr.Image(),
|
41 |
cache_examples=True)
|
42 |
demo.launch(debug=True)
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
opencv-python
|
2 |
encoded-video
|
3 |
torch
|
4 |
-
numpy
|
|
|
|
1 |
opencv-python
|
2 |
encoded-video
|
3 |
torch
|
4 |
+
numpy
|
5 |
+
gc-python-utils
|