Omnibus commited on
Commit
89cbab2
·
1 Parent(s): fd3fd55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -10
app.py CHANGED
@@ -42,19 +42,14 @@ def load_video(vid):
42
  print (msc)
43
  capture.release()
44
  vid_t = round(msc)
45
- #if vid_t <=59:
46
- # seconds = vid_t
47
- # minutes = "00"
48
- # hours = "00"
49
- #if vid_t >59 and vid_t <=359:
50
-
51
- # if vid_t >59 and vid_t<=360:minutes = (vid_t/60)
52
  hours = int(vid_t/360)
53
  minutes = int(vid_t/60)-(hours*360)
54
  seconds = vid_t-(minutes*60)-(hours*360)
55
 
56
 
57
  vid_len = f'{hours}:{minutes}:{seconds}'
 
58
  #vid_len_up = gr.update(label = "End", value = f"{vid_len}", placeholder = "0:00:54")
59
  return frame_count, fps, vid_len
60
 
@@ -175,7 +170,12 @@ def other():
175
  fbox3.append(f'{uid}-rembg/{i}.png')
176
  frame_num=f'Working on {i+1} of {frame_count}'
177
  yield fbox2,frame_num,None
178
-
 
 
 
 
 
179
  with gr.Blocks() as app:
180
  with gr.Tab("Load"):
181
  with gr.Row():
@@ -194,7 +194,7 @@ with gr.Blocks() as app:
194
  trim_count = gr.Textbox(label="Trimmed Frames")
195
  trim_btn=gr.Button("Trim")
196
  out_trim=gr.Video(format="mp4")
197
- hid_box = gr.Textbox(visible=False)
198
 
199
  with gr.Tab("Frames"):
200
  with gr.Row():
@@ -206,6 +206,17 @@ with gr.Blocks() as app:
206
  frame_gal = gr.Gallery(columns=6)
207
  with gr.Column():
208
  frame_file = gr.Files()
 
 
 
 
 
 
 
 
 
 
 
209
 
210
  with gr.Tab("Rem BG"):
211
  with gr.Row():
@@ -225,8 +236,9 @@ with gr.Blocks() as app:
225
  def echo_fn(inp):
226
  return inp
227
  #outp_vid.change(echo_fn,outp_vid,[out_trim])
 
228
  trim_btn.click(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
229
- outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f]).then(echo_fn,outp_vid,[out_trim])
230
  frame_btn.click(capture_function,[out_trim],[frame_gal,frame_file,frame_stat])
231
  rem_btn.click(rem_bg,[out_trim],[rem_vid,frame_num,rem_bg_vid])
232
  go_btn.click(dl,inp_url,[outp_vid,outp_file,out_trim,hid_box])
 
42
  print (msc)
43
  capture.release()
44
  vid_t = round(msc)
45
+
 
 
 
 
 
 
46
  hours = int(vid_t/360)
47
  minutes = int(vid_t/60)-(hours*360)
48
  seconds = vid_t-(minutes*60)-(hours*360)
49
 
50
 
51
  vid_len = f'{hours}:{minutes}:{seconds}'
52
+
53
  #vid_len_up = gr.update(label = "End", value = f"{vid_len}", placeholder = "0:00:54")
54
  return frame_count, fps, vid_len
55
 
 
170
  fbox3.append(f'{uid}-rembg/{i}.png')
171
  frame_num=f'Working on {i+1} of {frame_count}'
172
  yield fbox2,frame_num,None
173
+ def make_gif():
174
+ clip = f"{uid}-clip.mp4"
175
+ clip.write_gif(f"{uid}/clip_gif.gif")
176
+ out = f"{uid}/clip_gif.gif"
177
+ return out,out
178
+
179
  with gr.Blocks() as app:
180
  with gr.Tab("Load"):
181
  with gr.Row():
 
194
  trim_count = gr.Textbox(label="Trimmed Frames")
195
  trim_btn=gr.Button("Trim")
196
  out_trim=gr.Video(format="mp4")
197
+ hid_box = gr.Textbox(visible=True)
198
 
199
  with gr.Tab("Frames"):
200
  with gr.Row():
 
206
  frame_gal = gr.Gallery(columns=6)
207
  with gr.Column():
208
  frame_file = gr.Files()
209
+
210
+ with gr.Tab("GIF"):
211
+ with gr.Row():
212
+ gif_btn = gr.Button("Make GIF")
213
+ gif_stat=gr.Textbox("Status")
214
+
215
+ with gr.Row():
216
+ with gr.Column():
217
+ gif_show = gr.Video()
218
+ with gr.Column():
219
+ gif_file = gr.Files()
220
 
221
  with gr.Tab("Rem BG"):
222
  with gr.Row():
 
236
  def echo_fn(inp):
237
  return inp
238
  #outp_vid.change(echo_fn,outp_vid,[out_trim])
239
+ gif_btn.click(make_gif,None,[gif_show,gif_file])
240
  trim_btn.click(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
241
+ outp_vid.change(load_video,outp_vid,[frame_count,fps,end_f]).then(trim_vid,[hid_box,start_f,end_f],[out_trim,in_vid,trim_count])
242
  frame_btn.click(capture_function,[out_trim],[frame_gal,frame_file,frame_stat])
243
  rem_btn.click(rem_bg,[out_trim],[rem_vid,frame_num,rem_bg_vid])
244
  go_btn.click(dl,inp_url,[outp_vid,outp_file,out_trim,hid_box])