MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / run_generate

Function run_generate

src/common_ui.py:454–595  ·  view source on GitHub ↗
(*inputs)

Source from the content-addressed store, hash-verified

452
453
454def run_generate(*inputs):
455 inputs = GradioComponentBundle.enkey_to_dict(inputs)
456 depthmap_mode = inputs['depthmap_mode']
457 depthmap_batch_input_dir = inputs['depthmap_batch_input_dir']
458 image_batch = inputs['image_batch']
459 depthmap_input_image = inputs['depthmap_input_image']
460 depthmap_batch_output_dir = inputs['depthmap_batch_output_dir']
461 depthmap_batch_reuse = inputs['depthmap_batch_reuse']
462 custom_depthmap = inputs['custom_depthmap']
463 custom_depthmap_img = inputs['custom_depthmap_img']
464
465 inputimages = []
466 inputdepthmaps = [] # Allow supplying custom depthmaps
467 inputnames = [] # Also keep track of original file names
468
469 if depthmap_mode == '3':
470 try:
471 custom_depthmap = inputs['depthmap_vm_custom'] \
472 if inputs['depthmap_vm_custom_checkbox'] else None
473 colorvids_bitrate = inputs['depthmap_vm_compress_bitrate'] \
474 if inputs['depthmap_vm_compress_checkbox'] else None
475 ret = video_mode.gen_video(
476 inputs['depthmap_vm_input'], backbone.get_outpath(), inputs, custom_depthmap, colorvids_bitrate,
477 inputs['depthmap_vm_smoothening_mode'])
478 return [], None, None, ret
479 except Exception as e:
480 ret = format_exception(e)
481 return [], None, None, ret
482
483 if depthmap_mode == '2' and depthmap_batch_output_dir != '':
484 outpath = depthmap_batch_output_dir
485 else:
486 outpath = backbone.get_outpath()
487
488 if depthmap_mode == '0': # Single image
489 if depthmap_input_image is None:
490 return [], None, None, "Please select an input image"
491 inputimages.append(depthmap_input_image)
492 inputnames.append(None)
493 if custom_depthmap:
494 if custom_depthmap_img is None:
495 return [], None, None, \
496 "Custom depthmap is not specified. Please either supply it or disable this option."
497 inputdepthmaps.append(Image.open(os.path.abspath(custom_depthmap_img.name)))
498 else:
499 inputdepthmaps.append(None)
500 if depthmap_mode == '1': # Batch Process
501 if image_batch is None:
502 return [], None, None, "Please select input images", ""
503 for img in image_batch:
504 image = Image.open(os.path.abspath(img.name))
505 inputimages.append(image)
506 inputnames.append(os.path.splitext(img.orig_name)[0])
507 print(f'{len(inputimages)} images will be processed')
508 elif depthmap_mode == '2': # Batch from Directory
509 # TODO: There is a RAM leak when we process batches, I can smell it! Or maybe it is gone.
510 assert not backbone.get_cmd_opt('hide_ui_dir_config', False), '--hide-ui-dir-config option must be disabled'
511 if depthmap_batch_input_dir == '':

Callers

nothing calls this directly

Calls 5

core_generation_funnelFunction · 0.90
format_exceptionFunction · 0.85
enkey_to_dictMethod · 0.80
appendMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected