@@ -32,6 +32,9 @@ def __init__( self ):
32
32
self .fake_diff_int = tk .IntVar ()
33
33
self .CLIP_int = tk .IntVar ()
34
34
self .video_loaded = False
35
+ self .occluder_int = tk .IntVar ()
36
+ self .dock = True
37
+ self .undock = []
35
38
36
39
self .save_file = []
37
40
self .json_dict = {"source videos" :None , "source faces" :None , "saved videos" :None }
@@ -50,28 +53,35 @@ def __init__( self ):
50
53
self .video .grid ( row = 0 , column = 0 , columnspan = 3 , sticky = 'NEWS' , pady = 2 )
51
54
52
55
# Video button canvas
53
- self .video_button_canvas = tk .Canvas ( self .video_frame , width = 110 , height = 10 , bg = 'grey50' )
56
+ self .video_button_canvas = tk .Canvas ( self .video_frame , width = 125 , height = 10 , bg = 'grey50' )
54
57
self .video_button_canvas .grid ( row = 1 , column = 0 , sticky = 'NEWS' , pady = 5 )
55
58
59
+ # Dock
60
+ self .video_dock = tk .Button ( self .video_button_canvas , bg = 'grey50' , text = "^^" , wraplength = 1 , command = lambda : self .toggle_dock ())
61
+ self .video_dock .place (x = 5 , y = 5 , width = 15 , height = 33 )
62
+
56
63
# Video Swap
57
64
self .video_swap = tk .Button ( self .video_button_canvas , bg = 'grey50' , text = "SWP" , command = lambda : self .toggle_swapper ())
58
- self .video_swap .place (x = 5 , y = 5 , width = 33 , height = 33 )
65
+ self .video_swap .place (x = 22 , y = 5 , width = 33 , height = 33 )
59
66
60
67
# Video Play
61
68
self .video_play = tk .Button ( self .video_button_canvas , bg = 'grey50' , text = "PLY" , command = lambda : self .toggle_play_video ())
62
- self .video_play .place (x = 40 , y = 5 , width = 33 , height = 33 )
69
+ self .video_play .place (x = 57 , y = 5 , width = 33 , height = 33 )
63
70
64
71
# Video Record
65
72
self .video_record = tk .Button ( self .video_button_canvas , bg = 'grey50' , text = "REC" , command = lambda : self .toggle_rec_video ())
66
- self .video_record .place (x = 75 , y = 5 , width = 33 , height = 33 )
73
+ self .video_record .place (x = 92 , y = 5 , width = 33 , height = 33 )
67
74
68
75
# Video Slider
69
76
self .video_slider = tk .Scale ( self .video_frame , orient = 'horizontal' , bg = 'grey50' )
70
77
self .video_slider .bind ("<B1-Motion>" , lambda event :self .add_action ("set_video_position" , self .video_slider .get ()))
71
78
self .video_slider .bind ("<ButtonPress-1>" , lambda event :self .add_action ("set_video_position" , self .video_slider .get ()))
72
79
self .video_slider .bind ("<ButtonRelease-1>" , lambda event :self .add_action ("set_video_position" , self .video_slider .get ()))
80
+ self .video_slider .bind ("<MouseWheel>" , self .mouse_wheel )
73
81
self .video_slider .grid ( row = 1 , column = 1 , sticky = 'NEWS' , pady = 5 )
74
82
83
+
84
+
75
85
######## Found Faces
76
86
# Found Faces frame [1,0]
77
87
self .found_faces_frame = tk .Frame ( self , bg = 'grey20' )
@@ -190,15 +200,16 @@ def __init__( self ):
190
200
self .gfpgan_checkbox = tk .Checkbutton (self .label_frame1 , anchor = "w" , text = 'GFPGAN' ,variable = self .GFPGAN_int , bg = 'grey75' , height = 1 , onvalue = True , offvalue = False , command = lambda : self .add_action_and_update_frame ("gfpgan_checkbox" , self .GFPGAN_int .get ()))
191
201
self .gfpgan_checkbox .place (x = 5 , y = 8 , width = 80 , height = 17 )
192
202
193
- self .GFPGAN_blend = tk .Spinbox ( self .label_frame1 , from_ = 0 , to = 100 , increment = 5 , width = 5 ,bd = 4 , command = lambda :self .add_action_and_update_frame ("GFPGAN_blend" ,self .GFPGAN_blend .get () ))
203
+ var = tk .IntVar (value = 100 )
204
+ self .GFPGAN_blend = tk .Spinbox ( self .label_frame1 , from_ = 0 , to = 100 , increment = 5 , width = 5 ,bd = 4 , textvariable = var , command = lambda :self .add_action_and_update_frame ("GFPGAN_blend" ,self .GFPGAN_blend .get () ))
194
205
self .GFPGAN_blend .place (x = 100 , y = 5 )
195
- self .GFPGAN_blend .insert (0 ,5 )
196
206
197
207
# Fake_diff
198
208
self .fake_diff_checkbox = tk .Checkbutton (self .label_frame1 , anchor = "w" , text = 'Diffing' ,variable = self .fake_diff_int , bg = 'grey75' , onvalue = True , offvalue = False , command = lambda : self .add_action_and_update_frame ("fake_diff_checkbox" , self .fake_diff_int .get ()))
199
209
self .fake_diff_checkbox .place (x = 5 , y = 38 , width = 80 , height = 17 )
200
210
201
- self .fake_diff_blend = tk .Spinbox ( self .label_frame1 , from_ = 0 , to = 255 , increment = 1 , width = 5 ,bd = 4 , command = lambda :self .add_action_and_update_frame ("fake_diff_blend" ,self .fake_diff_blend .get () ))
211
+ var = tk .IntVar (value = 4 )
212
+ self .fake_diff_blend = tk .Spinbox ( self .label_frame1 , from_ = 0 , to = 255 , increment = 1 , width = 5 ,bd = 4 , textvariable = var , command = lambda :self .add_action_and_update_frame ("fake_diff_blend" ,self .fake_diff_blend .get () ))
202
213
self .fake_diff_blend .place (x = 100 , y = 35 )
203
214
204
215
# Face Threshhold
@@ -216,29 +227,21 @@ def __init__( self ):
216
227
self .top_blend_id = tk .Label (self .label_frame2 , anchor = "w" , bg = 'grey75' , text = "Mask top:" )
217
228
self .top_blend_id .place (x = 5 , y = 8 , width = 60 , height = 17 )
218
229
219
- var = tk .IntVar (value = 10 )
230
+ var = tk .IntVar (value = 20 )
220
231
self .top_blend_scrollbar = tk .Spinbox ( self .label_frame2 , from_ = 0 , to = 255 , increment = 1 , width = 5 ,bd = 4 , textvariable = var , command = lambda : self .add_action_and_update_frame ("top_blend" , self .top_blend_scrollbar .get ()) )
221
232
self .top_blend_scrollbar .place (x = 70 , y = 5 )
222
-
223
- # var = tk.IntVar(value=10)
224
- # self.bottom_blend_scrollbar = tk.Spinbox( self.label_frame2, from_=0, to=255, increment = 1, width = 5 ,bd = 4, textvariable=var, command=lambda : self.add_action_and_update_frame("bottom_blend",self.bottom_blend_scrollbar.get() ))
225
- # self.bottom_blend_scrollbar.place(x=30, y=65)
226
-
233
+
227
234
self .left_blend_id = tk .Label (self .label_frame2 , anchor = "w" , bg = 'grey75' , text = "Mask side:" )
228
235
self .left_blend_id .place (x = 5 , y = 38 , width = 60 , height = 17 )
229
236
230
- var = tk .IntVar (value = 10 )
237
+ var = tk .IntVar (value = 50 )
231
238
self .left_blend_scrollbar = tk .Spinbox ( self .label_frame2 , from_ = 0 , to = 255 , increment = 1 , width = 5 ,bd = 4 , textvariable = var , command = lambda : self .add_action_and_update_frame ("left_blend" ,self .left_blend_scrollbar .get () ))
232
239
self .left_blend_scrollbar .place (x = 70 , y = 35 )
233
-
234
- # var = tk.IntVar(value=8)
235
- # self.right_blend_scrollbar = tk.Spinbox( self.label_frame2, from_=0, to=255, increment = 1, width = 5 ,bd = 4, textvariable=var, command=lambda : self.add_action_and_update_frame("right_blend",self.right_blend_scrollbar.get() ))
236
- # self.right_blend_scrollbar.place(x=60, y=35)
237
-
240
+
238
241
self .mask_blur_id = tk .Label (self .label_frame2 , anchor = "w" , bg = 'grey75' , text = "Mask blur:" )
239
242
self .mask_blur_id .place (x = 5 , y = 68 , width = 60 , height = 17 )
240
243
241
- var = tk .IntVar (value = 10 )
244
+ var = tk .IntVar (value = 25 )
242
245
self .mask_blur_scrollbar = tk .Spinbox ( self .label_frame2 , from_ = 0 , to = 128 , increment = 1 , width = 5 ,bd = 4 , textvariable = var , command = lambda : self .add_action_and_update_frame ("blur" ,self .mask_blur_scrollbar .get () ))
243
246
self .mask_blur_scrollbar .place (x = 70 , y = 65 )
244
247
@@ -287,63 +290,86 @@ def __init__( self ):
287
290
var = tk .DoubleVar (value = 0.5 )
288
291
self .neg_thresh = tk .Spinbox ( self .label_frame3 , from_ = 0 , to = 1 , increment = 0.01 , width = 5 ,bd = 4 , textvariable = var , command = lambda :self .add_action_and_update_frame ("neg_thresh" ,float (self .neg_thresh .get ())))
289
292
self .neg_thresh .place (x = 195 , y = 65 )
290
-
291
-
292
293
293
-
294
-
295
294
# Label Frame 4
296
- self .label_frame4 = tk .LabelFrame ( self .options_frame_canvas1 , height = 100 , width = 210 , bg = 'grey50' )
297
- self .label_frame4 .place (x = 585 , y = 5 )
295
+ self .label_frame4 = tk .LabelFrame ( self .options_frame_canvas1 , height = 100 , width = 235 , bg = 'grey50' )
296
+ self .label_frame4 .place (x = 560 , y = 5 )
298
297
299
298
# Load all
300
299
self .create_video_button = tk .Button (self .label_frame4 , bg = 'gold' , text = "Load Models" , command = lambda : self .load_all ())
301
- self .create_video_button .place (x = 5 , y = 5 , width = 195 , height = 25 )
300
+ self .create_video_button .place (x = 5 , y = 5 , width = 90 , height = 25 )
302
301
303
302
# Save Videos Filepath
304
- self .save_video_filepath_button = tk .Button (self .label_frame4 , bg = 'gold' , text = "Set save videos folder" , wraplength = 115 , command = lambda : self .select_save_video_path ())
305
- self .save_video_filepath_button .place (x = 5 , y = 35 , width = 195 , height = 25 )
303
+ self .save_video_filepath_button = tk .Button (self .label_frame4 , bg = 'gold' , text = "Set save videos folder" , wraplength = 85 , command = lambda : self .select_save_video_path ())
304
+ self .save_video_filepath_button .place (x = 5 , y = 35 , width = 90 , height = 60 )
306
305
307
306
# Threads
308
307
var = tk .IntVar (value = 5 )
309
308
self .num_threads = tk .Spinbox ( self .label_frame4 , from_ = 0 , to = 20 , increment = 1 , width = 5 ,bd = 4 , textvariable = var , command = lambda :self .add_action ("num_threads" ,int (self .num_threads .get ())))
310
- self .num_threads .place (x = 75 , y = 65 )
309
+ self .num_threads .place (x = 155 , y = 5 )
311
310
312
- self .num_threads_id = tk .Label (self .label_frame4 , anchor = "w" , bg = 'grey75' , text = "# Threads:" )
313
- self .num_threads_id .place (x = 5 , y = 68 , width = 65 , height = 17 )
311
+ self .num_threads_id = tk .Label (self .label_frame4 , anchor = "w" , bg = 'grey75' , text = "Threads:" )
312
+ self .num_threads_id .place (x = 100 , y = 8 , width = 50 , height = 17 )
314
313
314
+ self .occluder_checkbox = tk .Checkbutton (self .label_frame4 , anchor = "w" , text = 'Occluder' ,variable = self .occluder_int , bg = 'grey75' , onvalue = True , offvalue = False , command = lambda : self .add_action_and_update_frame ("toggle_occluder" , self .occluder_int .get ()))
315
+ self .occluder_checkbox .place (x = 100 , y = 38 , height = 17 )
316
+
317
+ var = tk .IntVar (value = 25 )
318
+ self .occluder_blur = tk .Spinbox ( self .label_frame4 , from_ = 0 , to = 128 , increment = 1 , width = 5 ,bd = 4 , textvariable = var , command = lambda :self .add_action_and_update_frame ("occluder_blur" ,int (self .occluder_blur .get ())))
319
+ self .occluder_blur .place (x = 100 , y = 65 )
315
320
316
-
321
+ var = tk .IntVar (value = 5 )
322
+ self .occluder_limit = tk .Spinbox ( self .label_frame4 , from_ = 0 , to = 255 , increment = 1 , width = 5 ,bd = 4 , textvariable = var , command = lambda :self .add_action_and_update_frame ("occluder_limit" ,int (self .occluder_limit .get ())))
323
+ self .occluder_limit .place (x = 155 , y = 65 )
324
+
325
+ # Status
326
+ self .status_frame = tk .Frame ( self , bg = 'grey20' , height = 15 )
327
+ self .status_frame .grid ( row = 5 , column = 0 , sticky = 'NEWS' , pady = 2 )
328
+
329
+ self .status_label = tk .Label (self .status_frame , fg = "white" , bg = 'grey20' )
330
+ self .status_label .pack ()
331
+ # self.status_label_text = tk.Label(self.status_frame, anchor="w", bg='grey75', text="Threads:")
332
+ # self.status_label_text.place(x=100, y=8, width = 50, height=17)
333
+
317
334
318
335
def initialize_gui ( self ):
319
- self . geometry ( "800x800" )
320
- self .title ("Rope" )
336
+
337
+ self .title ("Rope - Space Worm " )
321
338
self .configure (bg = 'grey10' )
322
- self .resizable (width = True , height = True )
339
+ self .resizable (width = True , height = True )
340
+
341
+ self .geometry ('%dx%d+%d+%d' % (800 , 1020 , self .winfo_screenwidth ()/ 2 - 400 , self .winfo_screenheight ()/ 2 - 510 ))
323
342
324
343
self .grid_columnconfigure (0 , weight = 1 )
325
344
326
345
self .grid_rowconfigure (0 , weight = 10 )
327
346
self .grid_rowconfigure (1 , weight = 0 )
328
347
self .grid_rowconfigure (2 , weight = 0 )
329
348
self .grid_rowconfigure (3 , weight = 0 )
330
- self .grid_rowconfigure (4 , weight = 0 )
349
+ self .grid_rowconfigure (4 , weight = 0 )
350
+ self .grid_rowconfigure (5 , weight = 0 )
331
351
352
+
353
+ self .add_action ("fake_diff_blend" ,self .fake_diff_blend .get ())
332
354
self .add_action ("num_threads" , int (self .num_threads .get ()))
333
355
self .add_action ("face_thresh" , float (self .face_thresh .get ()))
334
356
self .add_action ("top_blend" , self .top_blend_scrollbar .get ())
335
357
self .add_action ("bottom_blend" ,10 )
336
358
self .add_action ("left_blend" ,self .left_blend_scrollbar .get () )
337
- self .add_action ("right_blend" ,self .left_blend_scrollbar .get () )
338
- # self.add_action("blur",self.blur_scrollbar.get())
339
- self .add_action_and_update_frame ("blur" ,self .mask_blur_scrollbar .get () )
340
- self .add_action_and_update_frame ("CLIP_blur" ,float (self .CLIP_blur .get ()))
359
+ self .add_action ("blur" ,self .mask_blur_scrollbar .get () )
360
+ self .add_action ("CLIP_blur" ,float (self .CLIP_blur .get ()))
341
361
342
362
self .add_action ("CLIP_checkbox" , self .CLIP_int .get ())
343
363
self .add_action ("GFPGAN_blend" ,self .GFPGAN_blend .get ())
344
364
345
365
self .add_action ("pos_thresh" ,float (self .neg_thresh .get ()))
346
366
self .add_action ("neg_thresh" ,float (self .neg_thresh .get ()))
367
+ self .add_action ("toggle_occluder" , float (self .occluder_int .get ()))
368
+
369
+ self .add_action ("occluder_blur" ,int (self .occluder_blur .get ()))
370
+
371
+ self .add_action ("occluder_limit" ,int (self .occluder_limit .get ()))
372
+
347
373
348
374
try :
349
375
self .save_file = open ("data.json" , "r" )
@@ -381,7 +407,7 @@ def load_all(self):
381
407
382
408
def select_video_path (self ):
383
409
384
- self .json_dict ["source videos" ] = filedialog .askdirectory (title = "Select a target " )
410
+ self .json_dict ["source videos" ] = filedialog .askdirectory (title = "Select Target Videos Folder " )
385
411
386
412
self .video_filepath_button .configure (bg = 'grey75' , text = self .json_dict ["source videos" ])
387
413
@@ -390,7 +416,7 @@ def select_video_path(self):
390
416
391
417
392
418
def select_save_video_path (self ):
393
- self .json_dict ["saved videos" ] = filedialog .askdirectory (title = "Select a target " )
419
+ self .json_dict ["saved videos" ] = filedialog .askdirectory (title = "Select Save Video Folder " )
394
420
395
421
self .save_video_filepath_button .configure (bg = 'grey75' , text = self .json_dict ["saved videos" ])
396
422
@@ -401,7 +427,7 @@ def select_save_video_path(self):
401
427
402
428
def select_faces_path (self ):
403
429
404
- self .json_dict ["source faces" ] = filedialog .askdirectory (title = "Select a target " )
430
+ self .json_dict ["source faces" ] = filedialog .askdirectory (title = "Select Source Faces Folder " )
405
431
406
432
self .faces_filepath_button .configure (bg = 'grey75' , text = self .json_dict ["source faces" ])
407
433
@@ -632,6 +658,8 @@ def load_target_video(self, button, video_file):
632
658
633
659
if self .swap == True :
634
660
self .toggle_swapper ()
661
+ if self .play_video == True :
662
+ self .toggle_play_video ()
635
663
636
664
self .clear_faces ()
637
665
@@ -640,7 +668,7 @@ def set_image(self, image, requested):
640
668
self .video_image = image [0 ]
641
669
if not requested :
642
670
self .set_slider_position (image [1 ])
643
-
671
+ # @profile
644
672
def display_image_in_video_frame (self ):
645
673
646
674
image = self .video_image
@@ -790,11 +818,35 @@ def send_var(self):
790
818
791
819
def add_action_and_update_frame (self , action , parameter ):
792
820
self .add_action (action , parameter )
793
- self .add_action ("set_video_position" , self .video_slider .get ())
821
+ if not self .play_video :
822
+ self .add_action ("set_video_position" , self .video_slider .get ())
794
823
795
824
def apply_CLIPs (self ):
796
825
temp = [self .CLIP_pos_text .get (1.0 , "end-1c" ), self .CLIP_neg_text .get (1.0 , "end-1c" )]
797
826
self .add_action_and_update_frame ("apply_CLIPs" , temp )
798
-
799
-
800
827
828
+ def toggle_dock (self ):
829
+ self .dock = False
830
+ if not self .dock :
831
+ # self.video_frame.winfo_width()
832
+ self .grid_rowconfigure (0 , weight = 0 )
833
+ # self.geometry('%dx%d+%d+%d' % (800, 800, self.winfo_screenwidth()/2-400, self.winfo_screenheight()/2-400))
834
+ self .geometry ('%dx%d' % (self .winfo_width (), 515 ))
835
+ self .resizable (width = True , height = False )
836
+
837
+
838
+ self .undock = self .wm_manage (self .video_frame )
839
+
840
+ self .video_frame .config (width = 1024 , height = 768 )
841
+ self .video_frame .grid_propagate (0 )
842
+ def set_status (self , msg ):
843
+ self .status_label .configure (text = str (msg ))
844
+ self .status_label .pack ()
845
+
846
+ def mouse_wheel (self , event ):
847
+ if event .delta > 0 :
848
+ self .video_slider .set (self .video_slider .get ()+ 1 )
849
+ self .add_action ("set_video_position" , self .video_slider .get ())
850
+ else :
851
+ self .video_slider .set (self .video_slider .get ()- 1 )
852
+ self .add_action ("set_video_position" , self .video_slider .get ())
0 commit comments