Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -121,19 +121,25 @@ def predict(text, url_params):
|
|
121 |
print (mod_url)
|
122 |
return ["" + text + "", mod_url]
|
123 |
|
124 |
-
def dl(inp):
|
125 |
out = None
|
126 |
out_file=[]
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
fps = capture.get(cv2.CAP_PROP_FPS)
|
134 |
capture.release()
|
135 |
-
|
136 |
-
out = None
|
137 |
return out,out,out,out,fps
|
138 |
def dl_json(inp):
|
139 |
out_json={}
|
@@ -276,14 +282,22 @@ with gr.Blocks() as app:
|
|
276 |
|
277 |
def echo_fn(inp):
|
278 |
return inp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
#outp_vid.change(echo_fn,outp_vid,[out_trim])
|
280 |
info_btn.click(dl_json,inp_url,info_json)
|
281 |
speed_btn.click(update_speed,[hid_box,clip_speed,hid_fps],[outp_vid,hid_box])
|
282 |
gif_btn.click(make_gif,None,[gif_show,gif_file])
|
283 |
trim_btn.click(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
|
284 |
-
outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f]).then(
|
285 |
frame_btn.click(capture_function,[out_trim],[frame_gal,frame_file,frame_stat])
|
286 |
rem_btn.click(rem_bg,[out_trim],[rem_vid,frame_num,rem_bg_vid])
|
287 |
-
go_btn.click(dl,inp_url,[outp_vid,outp_file,out_trim,hid_box,hid_fps])
|
288 |
app.load(fn=predict, inputs=[text_input,url_params], outputs=[text_output,text_input],_js=load_js)
|
289 |
app.launch()
|
|
|
121 |
print (mod_url)
|
122 |
return ["" + text + "", mod_url]
|
123 |
|
124 |
+
def dl(inp,img):
|
125 |
out = None
|
126 |
out_file=[]
|
127 |
+
if img == None and inp !="":
|
128 |
+
try:
|
129 |
+
inp_out=inp.replace("https://","")
|
130 |
+
inp_out=inp_out.replace("/","_").replace(".","_").replace("=","_").replace("?","_")
|
131 |
+
os.system(f'yt-dlp "{inp}" --trim-filenames 160 -o "{uid}/{inp_out}.mp4" -S res,mp4 --recode mp4')
|
132 |
+
out = f"{uid}/{inp_out}.mp4"
|
133 |
+
capture = cv2.VideoCapture(out)
|
134 |
+
fps = capture.get(cv2.CAP_PROP_FPS)
|
135 |
+
capture.release()
|
136 |
+
except Exception as e:
|
137 |
+
out = None
|
138 |
+
elif img !=None and inp == "":
|
139 |
+
capture = cv2.VideoCapture(img)
|
140 |
fps = capture.get(cv2.CAP_PROP_FPS)
|
141 |
capture.release()
|
142 |
+
out = f"{img}"
|
|
|
143 |
return out,out,out,out,fps
|
144 |
def dl_json(inp):
|
145 |
out_json={}
|
|
|
282 |
|
283 |
def echo_fn(inp):
|
284 |
return inp
|
285 |
+
def check_load(inp_url,outp_vid,hid_box,start_f,end_f):
|
286 |
+
if outp_vid == None and inp_url !="":
|
287 |
+
out_trim,in_vid,trim_count=trim_vid(hid_box,start_f,end_f)
|
288 |
+
elif outp_vid !=None and inp_url == "":
|
289 |
+
out_trim = None
|
290 |
+
in_vid=outp_vid
|
291 |
+
trim_count = ""
|
292 |
+
return out_trim,in_vid,trim_count
|
293 |
#outp_vid.change(echo_fn,outp_vid,[out_trim])
|
294 |
info_btn.click(dl_json,inp_url,info_json)
|
295 |
speed_btn.click(update_speed,[hid_box,clip_speed,hid_fps],[outp_vid,hid_box])
|
296 |
gif_btn.click(make_gif,None,[gif_show,gif_file])
|
297 |
trim_btn.click(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
|
298 |
+
outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f]).then(check_load,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
|
299 |
frame_btn.click(capture_function,[out_trim],[frame_gal,frame_file,frame_stat])
|
300 |
rem_btn.click(rem_bg,[out_trim],[rem_vid,frame_num,rem_bg_vid])
|
301 |
+
go_btn.click(dl,[inp_url,outp_vid],[outp_vid,outp_file,out_trim,hid_box,hid_fps])
|
302 |
app.load(fn=predict, inputs=[text_input,url_params], outputs=[text_output,text_input],_js=load_js)
|
303 |
app.launch()
|