@@ -147,6 +147,8 @@ def main_ui_panel(is_depth_tab):
147147 with gr .Row (visible = False ) as stereo_options_row_1 :
148148 stereo_divergence = gr .Slider (minimum = 0.05 , maximum = 10.005 , step = 0.01 , label = 'Divergence (3D effect)' ,
149149 value = 2.5 )
150+ stereo_separation = gr .Slider (minimum = - 5.0 , maximum = 5.0 , step = 0.01 , label = 'Separation (moves images apart)' ,
151+ value = 0.0 )
150152 with gr .Row (visible = False ) as stereo_options_row_2 :
151153 stereo_fill = gr .Dropdown (label = "Gap fill technique" ,
152154 choices = ['none' , 'naive' , 'naive_interpolating' , 'polylines_soft' ,
@@ -266,7 +268,7 @@ def background_removal_options_visibility(v):
266268 outputs = [bgrem_options_row_1 , bgrem_options_row_2 ]
267269 )
268270
269- return [compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal , pre_depth_background_removal , background_removal_model , gen_mesh , mesh_occlude , mesh_spherical ]
271+ return [compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_separation , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal , pre_depth_background_removal , background_removal_model , gen_mesh , mesh_occlude , mesh_spherical ]
270272
271273
272274class Script (scripts .Script ):
@@ -283,7 +285,7 @@ def ui(self, is_img2img):
283285
284286 # run from script in txt2img or img2img
285287 def run (self , p ,
286- compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal , pre_depth_background_removal , background_removal_model , gen_mesh , mesh_occlude , mesh_spherical
288+ compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_separation , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal , pre_depth_background_removal , background_removal_model , gen_mesh , mesh_occlude , mesh_spherical
287289 ):
288290
289291 # sd process
@@ -309,7 +311,7 @@ def run(self, p,
309311
310312 newmaps , mesh_fi , meshsimple_fi = run_depthmap (processed , p .outpath_samples , inputimages , None ,
311313 compute_device , model_type ,
312- net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal ,
314+ net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_separation , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal ,
313315 background_removed_images , "mp4" , 0 , False , None , False , gen_mesh , mesh_occlude , mesh_spherical )
314316
315317 for img in newmaps :
@@ -328,7 +330,7 @@ def reload_sd_model():
328330 shared .sd_model .first_stage_model .to (devices .device )
329331
330332def run_depthmap (processed , outpath , inputimages , inputnames ,
331- compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal ,
333+ compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_separation , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal ,
332334 background_removed_images , fnExt , vid_ssaa , custom_depthmap , custom_depthmap_img , depthmap_batch_reuse , gen_mesh , mesh_occlude , mesh_spherical ):
333335
334336 if len (inputimages ) == 0 or inputimages [0 ] == None :
@@ -687,7 +689,7 @@ def run_depthmap(processed, outpath, inputimages, inputnames,
687689 try :
688690 images .save_image (Image .fromarray (img_output ), outpath , "" , processed .all_seeds [count ], processed .all_prompts [count ], opts .samples_format , info = info , p = processed , suffix = "_depth" )
689691 except ValueError as ve :
690- if not 'image has wrong mode' in str (ve ): raise ve
692+ if not ( 'image has wrong mode' in str (ve ) or 'cannot write mode I;16 as JPEG' in str ( ve ) ): raise ve
691693 else :
692694 images .save_image (Image .fromarray (img_output2 ), outpath , "" , processed .all_seeds [count ], processed .all_prompts [count ], opts .samples_format , info = info , p = processed , suffix = "_depth" )
693695 elif save_depth :
@@ -697,7 +699,7 @@ def run_depthmap(processed, outpath, inputimages, inputnames,
697699 try :
698700 images .save_image (Image .fromarray (img_output ), path = outpath , basename = basename , seed = None , prompt = None , extension = opts .samples_format , info = info , short_filename = True ,no_prompt = True , grid = False , pnginfo_section_name = "extras" , existing_info = None , forced_filename = None )
699701 except ValueError as ve :
700- if not 'image has wrong mode' in str (ve ): raise ve
702+ if not ( 'image has wrong mode' in str (ve ) or 'cannot write mode I;16 as JPEG' in str ( ve ) ): raise ve
701703 else :
702704 images .save_image (Image .fromarray (img_output2 ), path = outpath , basename = basename , seed = None , prompt = None , extension = opts .samples_format , info = info , short_filename = True ,no_prompt = True , grid = False , pnginfo_section_name = "extras" , existing_info = None , forced_filename = None )
703705 else :
@@ -714,7 +716,7 @@ def run_depthmap(processed, outpath, inputimages, inputnames,
714716 print ("Generating stereoscopic images.." )
715717
716718 stereomodes = stereo_modes
717- stereoimages = create_stereoimages (inputimages [count ], img_output , stereo_divergence , stereomodes , stereo_balance , stereo_fill )
719+ stereoimages = create_stereoimages (inputimages [count ], img_output , stereo_divergence , stereo_separation , stereomodes , stereo_balance , stereo_fill )
718720
719721 for c in range (0 , len (stereoimages )):
720722 outimages .append (stereoimages [c ])
@@ -1138,6 +1140,7 @@ def run_generate(depthmap_mode,
11381140 gen_stereo ,
11391141 stereo_modes ,
11401142 stereo_divergence ,
1143+ stereo_separation ,
11411144 stereo_fill ,
11421145 stereo_balance ,
11431146 inpaint ,
@@ -1205,7 +1208,7 @@ def run_generate(depthmap_mode,
12051208
12061209 outputs , mesh_fi , meshsimple_fi = run_depthmap (
12071210 None , outpath , imageArr , imageNameArr ,
1208- compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal ,
1211+ compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_separation , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal ,
12091212 background_removed_images , fnExt , vid_ssaa , custom_depthmap , custom_depthmap_img , depthmap_batch_reuse , gen_mesh , mesh_occlude , mesh_spherical )
12101213
12111214 # use inpainted 3d mesh to show in 3d model output when enabled in settings
@@ -1264,7 +1267,7 @@ def on_ui_tabs():
12641267 submit = gr .Button ('Generate' , elem_id = "depthmap_generate" , variant = 'primary' )
12651268
12661269 # insert main panel
1267- compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal , pre_depth_background_removal , background_removal_model , gen_mesh , mesh_occlude , mesh_spherical = main_ui_panel (True )
1270+ compute_device , model_type , net_width , net_height , match_size , boost , invert_depth , clipdepth , clipthreshold_far , clipthreshold_near , combine_output , combine_output_axis , save_depth , show_depth , show_heat , gen_stereo , stereo_modes , stereo_divergence , stereo_separation , stereo_fill , stereo_balance , inpaint , inpaint_vids , background_removal , save_background_removal_masks , gen_normal , pre_depth_background_removal , background_removal_model , gen_mesh , mesh_occlude , mesh_spherical = main_ui_panel (True )
12681271
12691272 unloadmodels = gr .Button ('Unload models' , elem_id = "depthmap_unloadmodels" )
12701273
@@ -1357,6 +1360,7 @@ def custom_depthmap_visibility(v):
13571360 gen_stereo ,
13581361 stereo_modes ,
13591362 stereo_divergence ,
1363+ stereo_separation ,
13601364 stereo_fill ,
13611365 stereo_balance ,
13621366 inpaint ,
0 commit comments