(self, p, *inputs)
| 28 | |
| 29 | # run from script in txt2img or img2img |
| 30 | def run(self, p, *inputs): |
| 31 | from modules import processing |
| 32 | from modules.processing import create_infotext |
| 33 | |
| 34 | inputs = GradioComponentBundle.enkey_to_dict(inputs) |
| 35 | |
| 36 | # sd process |
| 37 | processed = processing.process_images(p) |
| 38 | processed.sampler = p.sampler # for create_infotext |
| 39 | processed.tiling = p.tiling # for create_infotext |
| 40 | |
| 41 | inputimages = [] |
| 42 | for count in range(0, len(processed.images)): |
| 43 | # skip first grid image |
| 44 | if count == 0 and len(processed.images) > 1 and shared.opts.return_grid: |
| 45 | continue |
| 46 | inputimages.append(processed.images[count]) |
| 47 | |
| 48 | gen_obj = core_generation_funnel(p.outpath_samples, inputimages, None, None, inputs, backbone.gather_ops()) |
| 49 | |
| 50 | for input_i, type, result in gen_obj: |
| 51 | if not isinstance(result, Image.Image): |
| 52 | continue |
| 53 | |
| 54 | # get generation parameters |
| 55 | # TODO: could reuse |
| 56 | if hasattr(processed, 'all_prompts') and shared.opts.enable_pnginfo: |
| 57 | info = create_infotext( |
| 58 | p, processed.all_prompts, processed.all_seeds, processed.all_subseeds, "", 0, input_i) |
| 59 | else: |
| 60 | info = None |
| 61 | |
| 62 | processed.images.append(result) |
| 63 | if inputs["save_outputs"]: |
| 64 | try: |
| 65 | suffix = "" if type == "depth" else f"{type}" |
| 66 | backbone.save_image(result, path=p.outpath_samples, basename="", seed=processed.all_seeds[input_i], |
| 67 | prompt=processed.all_prompts[input_i], extension=shared.opts.samples_format, |
| 68 | info=info, |
| 69 | p=processed, |
| 70 | suffix=suffix) |
| 71 | except Exception as e: |
| 72 | if not ('image has wrong mode' in str(e) or 'I;16' in str(e)): |
| 73 | raise e |
| 74 | print('Catched exception: image has wrong mode!') |
| 75 | traceback.print_exc() |
| 76 | return processed |
| 77 | |
| 78 | |
| 79 | # TODO: some of them may be put into the main ui pane |
nothing calls this directly
no test coverage detected