Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,12 @@ 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 get_frames(video_in):
|
| 11 |
frames = []
|
| 12 |
# Opens the Video file
|
|
@@ -34,8 +40,9 @@ def create_video(frames, fps):
|
|
| 34 |
return 'movie.mp4'
|
| 35 |
|
| 36 |
|
| 37 |
-
def infer(prompt,video_in, seed_in):
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
frames_list= break_vid[0]
|
| 41 |
fps = break_vid[1]
|
|
@@ -57,12 +64,14 @@ with gr.Blocks(css='style.css') as demo:
|
|
| 57 |
with gr.Row():
|
| 58 |
prompt = gr.Textbox(placeholder="enter prompt")
|
| 59 |
video_inp = gr.Video(label="Video source", source="upload", type="filepath")
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
with gr.Column():
|
| 62 |
video_out = gr.Video(label="Pix2pix video result")
|
| 63 |
submit_btn = gr.Button("Generate Pix2Pix video")
|
| 64 |
|
| 65 |
-
inputs = [prompt,video_inp,seed_inp]
|
| 66 |
outputs = [video_out]
|
| 67 |
|
| 68 |
submit_btn.click(infer, inputs, outputs)
|
|
|
|
| 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('Test_video.mp4')
|
| 12 |
+
clip1 = clip.subclip((0,00),(trim_value))
|
| 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
|
|
|
|
| 40 |
return 'movie.mp4'
|
| 41 |
|
| 42 |
|
| 43 |
+
def infer(prompt,video_in, seed_in, trim_value):
|
| 44 |
+
trimmed_vid = trim_video(video_in, trim_value)
|
| 45 |
+
break_vid = get_frames(trimmed_vid)
|
| 46 |
|
| 47 |
frames_list= break_vid[0]
|
| 48 |
fps = break_vid[1]
|
|
|
|
| 64 |
with gr.Row():
|
| 65 |
prompt = gr.Textbox(placeholder="enter prompt")
|
| 66 |
video_inp = gr.Video(label="Video source", source="upload", type="filepath")
|
| 67 |
+
with gr.Row():
|
| 68 |
+
seed_inp = gr.Number(label="Seed", value=123456)
|
| 69 |
+
trim_in = gr.Slider(minimun=2.00, maximum=10.00, step=1.00, value=2.00)
|
| 70 |
with gr.Column():
|
| 71 |
video_out = gr.Video(label="Pix2pix video result")
|
| 72 |
submit_btn = gr.Button("Generate Pix2Pix video")
|
| 73 |
|
| 74 |
+
inputs = [prompt,video_inp,seed_inp, trim_in]
|
| 75 |
outputs = [video_out]
|
| 76 |
|
| 77 |
submit_btn.click(infer, inputs, outputs)
|