Spaces:
Running
on
A10G
Running
on
A10G
Update app.py
Browse files
app.py
CHANGED
@@ -7,12 +7,6 @@ from moviepy.editor import *
|
|
7 |
token = os.environ.get('HF_TOKEN')
|
8 |
pix2pix = gr.Blocks.load(name="spaces/fffiloni/instruct-pix2pix-clone", api_key=token)
|
9 |
|
10 |
-
def trim_video(video_in, trim_value):
|
11 |
-
clip = VideoFileClip(video_in)
|
12 |
-
clip1 = clip.subclip((0,00),(trim_value,00))
|
13 |
-
clip1.write_videofile('edited.mp4',codec='libx264')
|
14 |
-
return 'edited.mp4'
|
15 |
-
|
16 |
def get_frames(video_in):
|
17 |
frames = []
|
18 |
# Opens the Video file
|
@@ -41,17 +35,19 @@ def create_video(frames, fps):
|
|
41 |
|
42 |
|
43 |
def infer(prompt,video_in, seed_in, trim_value):
|
44 |
-
|
45 |
-
break_vid = get_frames(
|
46 |
|
47 |
frames_list= break_vid[0]
|
48 |
fps = break_vid[1]
|
|
|
49 |
result_frames = []
|
50 |
|
51 |
-
for i in frames_list:
|
52 |
pix2pix_img = pix2pix(prompt,5.5,1.5,i,15,"",512,512,seed_in,fn_index=0)
|
53 |
images = [os.path.join(pix2pix_img[0], img) for img in os.listdir(pix2pix_img[0])]
|
54 |
result_frames.append(images[0])
|
|
|
55 |
|
56 |
final_vid = create_video(result_frames, fps)
|
57 |
|
@@ -68,7 +64,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
68 |
with gr.Column():
|
69 |
with gr.Row():
|
70 |
seed_inp = gr.Slider(minimum=0, maximum=10000, step=1, value=123456)
|
71 |
-
trim_in = gr.Slider(label="video
|
72 |
video_out = gr.Video(label="Pix2pix video result")
|
73 |
submit_btn = gr.Button("Generate Pix2Pix video")
|
74 |
|
|
|
7 |
token = os.environ.get('HF_TOKEN')
|
8 |
pix2pix = gr.Blocks.load(name="spaces/fffiloni/instruct-pix2pix-clone", api_key=token)
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
def get_frames(video_in):
|
11 |
frames = []
|
12 |
# Opens the Video file
|
|
|
35 |
|
36 |
|
37 |
def infer(prompt,video_in, seed_in, trim_value):
|
38 |
+
|
39 |
+
break_vid = get_frames(video_in)
|
40 |
|
41 |
frames_list= break_vid[0]
|
42 |
fps = break_vid[1]
|
43 |
+
n_frame = trim_value*fps
|
44 |
result_frames = []
|
45 |
|
46 |
+
for i in frames_list[0:n_frame]:
|
47 |
pix2pix_img = pix2pix(prompt,5.5,1.5,i,15,"",512,512,seed_in,fn_index=0)
|
48 |
images = [os.path.join(pix2pix_img[0], img) for img in os.listdir(pix2pix_img[0])]
|
49 |
result_frames.append(images[0])
|
50 |
+
print("frame " + i + ": done;")
|
51 |
|
52 |
final_vid = create_video(result_frames, fps)
|
53 |
|
|
|
64 |
with gr.Column():
|
65 |
with gr.Row():
|
66 |
seed_inp = gr.Slider(minimum=0, maximum=10000, step=1, value=123456)
|
67 |
+
trim_in = gr.Slider(label="Cut video at (s)", minimun=2, maximum=10, step=1, value=2)
|
68 |
video_out = gr.Video(label="Pix2pix video result")
|
69 |
submit_btn = gr.Button("Generate Pix2Pix video")
|
70 |
|