@@ -205,7 +205,7 @@ def __init__(self, *args, **kwargs):
205205]
206206
207207
208- def draw_xyz_grid (p , xs , ys , zs , x_labels , y_labels , z_labels , cell , draw_legend , include_lone_images , include_sub_grids , first_axes_processed , second_axes_processed ):
208+ def draw_xyz_grid (p , xs , ys , zs , x_labels , y_labels , z_labels , cell , draw_legend , include_lone_images , include_sub_grids , first_axes_processed , second_axes_processed , margin_size ):
209209 hor_texts = [[images .GridAnnotation (x )] for x in x_labels ]
210210 ver_texts = [[images .GridAnnotation (y )] for y in y_labels ]
211211 title_texts = [[images .GridAnnotation (z )] for z in z_labels ]
@@ -292,7 +292,7 @@ def index(ix, iy, iz):
292292 end_index = start_index + len (xs ) * len (ys )
293293 grid = images .image_grid (image_cache [start_index :end_index ], rows = len (ys ))
294294 if draw_legend :
295- grid = images .draw_grid_annotations (grid , cell_size [0 ], cell_size [1 ], hor_texts , ver_texts )
295+ grid = images .draw_grid_annotations (grid , cell_size [0 ], cell_size [1 ], hor_texts , ver_texts , margin_size )
296296 sub_grids [i ] = grid
297297 if include_sub_grids and len (zs ) > 1 :
298298 processed_result .images .insert (i + 1 , grid )
@@ -351,10 +351,16 @@ def ui(self, is_img2img):
351351 fill_z_button = ToolButton (value = fill_values_symbol , elem_id = "xyz_grid_fill_z_tool_button" , visible = False )
352352
353353 with gr .Row (variant = "compact" , elem_id = "axis_options" ):
354- draw_legend = gr .Checkbox (label = 'Draw legend' , value = True , elem_id = self .elem_id ("draw_legend" ))
355- include_lone_images = gr .Checkbox (label = 'Include Sub Images' , value = False , elem_id = self .elem_id ("include_lone_images" ))
356- include_sub_grids = gr .Checkbox (label = 'Include Sub Grids' , value = False , elem_id = self .elem_id ("include_sub_grids" ))
357- no_fixed_seeds = gr .Checkbox (label = 'Keep -1 for seeds' , value = False , elem_id = self .elem_id ("no_fixed_seeds" ))
354+ with gr .Column ():
355+ draw_legend = gr .Checkbox (label = 'Draw legend' , value = True , elem_id = self .elem_id ("draw_legend" ))
356+ no_fixed_seeds = gr .Checkbox (label = 'Keep -1 for seeds' , value = False , elem_id = self .elem_id ("no_fixed_seeds" ))
357+ with gr .Column ():
358+ include_lone_images = gr .Checkbox (label = 'Include Sub Images' , value = False , elem_id = self .elem_id ("include_lone_images" ))
359+ include_sub_grids = gr .Checkbox (label = 'Include Sub Grids' , value = False , elem_id = self .elem_id ("include_sub_grids" ))
360+ with gr .Column ():
361+ margin_size = gr .Slider (label = "Grid margins (px)" , min = 0 , max = 500 , value = 0 , step = 2 , elem_id = self .elem_id ("margin_size" ))
362+
363+ with gr .Row (variant = "compact" , elem_id = "swap_axes" ):
358364 swap_xy_axes_button = gr .Button (value = "Swap X/Y axes" , elem_id = "xy_grid_swap_axes_button" )
359365 swap_yz_axes_button = gr .Button (value = "Swap Y/Z axes" , elem_id = "yz_grid_swap_axes_button" )
360366 swap_xz_axes_button = gr .Button (value = "Swap X/Z axes" , elem_id = "xz_grid_swap_axes_button" )
@@ -393,9 +399,9 @@ def select_axis(x_type):
393399 (z_values , "Z Values" ),
394400 )
395401
396- return [x_type , x_values , y_type , y_values , z_type , z_values , draw_legend , include_lone_images , include_sub_grids , no_fixed_seeds ]
402+ return [x_type , x_values , y_type , y_values , z_type , z_values , draw_legend , include_lone_images , include_sub_grids , no_fixed_seeds , margin_size ]
397403
398- def run (self , p , x_type , x_values , y_type , y_values , z_type , z_values , draw_legend , include_lone_images , include_sub_grids , no_fixed_seeds ):
404+ def run (self , p , x_type , x_values , y_type , y_values , z_type , z_values , draw_legend , include_lone_images , include_sub_grids , no_fixed_seeds , margin_size ):
399405 if not no_fixed_seeds :
400406 modules .processing .fix_seed (p )
401407
@@ -590,7 +596,8 @@ def cell(x, y, z):
590596 include_lone_images = include_lone_images ,
591597 include_sub_grids = include_sub_grids ,
592598 first_axes_processed = first_axes_processed ,
593- second_axes_processed = second_axes_processed
599+ second_axes_processed = second_axes_processed ,
600+ margin_size = margin_size
594601 )
595602
596603 if opts .grid_save and len (sub_grids ) > 1 :
0 commit comments