Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -153,7 +153,7 @@ def video_clip(program,fps,qual,model_name,denoise_strength,face_enhance,outscal
|
|
153 |
out = f"{uid}/enhanced_vid.mp4"
|
154 |
yield out,out,"Video Complete"
|
155 |
|
156 |
-
def gif_clip(program,fps,qual,model_name,denoise_strength,face_enhance,outscale):
|
157 |
_=None
|
158 |
fps=float(fps)
|
159 |
new_video_in = str(f"{uid}-clip.mp4")
|
@@ -192,13 +192,21 @@ def gif_clip(program,fps,qual,model_name,denoise_strength,face_enhance,outscale)
|
|
192 |
print (f'out_box::{out_box}')
|
193 |
clip = ImageSequenceClip(out_box, fps = fps)
|
194 |
else:
|
195 |
-
mes="Writing GIF"
|
196 |
clip = ImageSequenceClip(fbox, fps = fps)
|
197 |
-
yield _,_,"Writing
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
203 |
|
204 |
def update_speed(inp,clip_speed,fps):
|
@@ -251,7 +259,7 @@ with gr.Blocks(css=css) as app:
|
|
251 |
with gr.Tab("Image"):
|
252 |
with gr.Group():
|
253 |
inp_img_url=gr.Textbox(label="Image URL")
|
254 |
-
inp_img=gr.Image(label = "Input Image")
|
255 |
outp_img=gr.Image(label="Enhanced Image")
|
256 |
with gr.Tab("Video/GIF"):
|
257 |
with gr.Group():
|
@@ -338,7 +346,7 @@ with gr.Blocks(css=css) as app:
|
|
338 |
yield out,"Sample Frame Complete"
|
339 |
samp_btn.click(run_samp,[choose_prog,fps,qual,model_name,denoise_strength,face_enhance,outscale,frame_targ],[samp_im,gif_stat])
|
340 |
speed_btn.click(update_speed,[hid_box,clip_speed,hid_fps],[outp_vid,hid_box,outp_file])
|
341 |
-
gif_btn.click(gif_clip,[choose_prog,fps,qual,model_name,denoise_strength,face_enhance,outscale],[gif_show,gif_file,gif_stat])
|
342 |
trim_btn.click(trim_vid,[hid_box,start_f,end_f],[out_trim,trim_count])
|
343 |
outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f,hid_box,idx_vid]).then(trim_vid,[hid_box,start_f,end_f],[out_trim,trim_count])
|
344 |
go_btn.click(dl,[inp_url,outp_vid],[outp_vid,outp_file,out_trim,hid_box,hid_fps])
|
|
|
153 |
out = f"{uid}/enhanced_vid.mp4"
|
154 |
yield out,out,"Video Complete"
|
155 |
|
156 |
+
def gif_clip(program,fps,qual,model_name,denoise_strength,face_enhance,outscale,idx_vid):
|
157 |
_=None
|
158 |
fps=float(fps)
|
159 |
new_video_in = str(f"{uid}-clip.mp4")
|
|
|
192 |
print (f'out_box::{out_box}')
|
193 |
clip = ImageSequenceClip(out_box, fps = fps)
|
194 |
else:
|
|
|
195 |
clip = ImageSequenceClip(fbox, fps = fps)
|
196 |
+
yield _,_,"Writing"
|
197 |
+
if idx_vid == "GIF":
|
198 |
+
clip.speedx(2).to_gif(f"{uid}/clip_gif.gif",program=program)
|
199 |
+
out = f"{uid}/clip_gif.gif"
|
200 |
+
yield out,out,"GIF Complete"
|
201 |
+
|
202 |
+
if idx_vid == "Video"
|
203 |
+
videoclip = VideoFileClip(new_video_in)
|
204 |
+
audioclip=videoclip.audio
|
205 |
+
#clip = moviepy.video.io.ImageSequenceClip.ImageSequenceClip(images, fps)
|
206 |
+
clip.audio=audioclip
|
207 |
+
clip.write_videofile(f"{uid}/enhanced_vid.mp4")
|
208 |
+
out = f"{uid}/enhanced_vid.mp4"
|
209 |
+
yield out,out,"Video Complete"
|
210 |
|
211 |
|
212 |
def update_speed(inp,clip_speed,fps):
|
|
|
259 |
with gr.Tab("Image"):
|
260 |
with gr.Group():
|
261 |
inp_img_url=gr.Textbox(label="Image URL")
|
262 |
+
inp_img=gr.Image(label = "Input Image")
|
263 |
outp_img=gr.Image(label="Enhanced Image")
|
264 |
with gr.Tab("Video/GIF"):
|
265 |
with gr.Group():
|
|
|
346 |
yield out,"Sample Frame Complete"
|
347 |
samp_btn.click(run_samp,[choose_prog,fps,qual,model_name,denoise_strength,face_enhance,outscale,frame_targ],[samp_im,gif_stat])
|
348 |
speed_btn.click(update_speed,[hid_box,clip_speed,hid_fps],[outp_vid,hid_box,outp_file])
|
349 |
+
gif_btn.click(gif_clip,[choose_prog,fps,qual,model_name,denoise_strength,face_enhance,outscale,idx_vid],[gif_show,gif_file,gif_stat])
|
350 |
trim_btn.click(trim_vid,[hid_box,start_f,end_f],[out_trim,trim_count])
|
351 |
outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f,hid_box,idx_vid]).then(trim_vid,[hid_box,start_f,end_f],[out_trim,trim_count])
|
352 |
go_btn.click(dl,[inp_url,outp_vid],[outp_vid,outp_file,out_trim,hid_box,hid_fps])
|