(*args)
| 20 | |
| 21 | |
| 22 | def run(*args): |
| 23 | id_image = args[0] |
| 24 | supp_images = args[1:4] |
| 25 | prompt, neg_prompt, scale, n_samples, seed, steps, H, W, id_scale, mode, id_mix = args[4:] |
| 26 | |
| 27 | pipeline.debug_img_list = [] |
| 28 | if mode == 'fidelity': |
| 29 | attention.NUM_ZERO = 8 |
| 30 | attention.ORTHO = False |
| 31 | attention.ORTHO_v2 = True |
| 32 | elif mode == 'extremely style': |
| 33 | attention.NUM_ZERO = 16 |
| 34 | attention.ORTHO = True |
| 35 | attention.ORTHO_v2 = False |
| 36 | else: |
| 37 | raise ValueError |
| 38 | |
| 39 | if id_image is not None: |
| 40 | id_image = resize_numpy_image_long(id_image, 1024) |
| 41 | id_embeddings = pipeline.get_id_embedding(id_image) |
| 42 | for supp_id_image in supp_images: |
| 43 | if supp_id_image is not None: |
| 44 | supp_id_image = resize_numpy_image_long(supp_id_image, 1024) |
| 45 | supp_id_embeddings = pipeline.get_id_embedding(supp_id_image) |
| 46 | id_embeddings = torch.cat( |
| 47 | (id_embeddings, supp_id_embeddings if id_mix else supp_id_embeddings[:, :5]), dim=1 |
| 48 | ) |
| 49 | else: |
| 50 | id_embeddings = None |
| 51 | |
| 52 | seed_everything(seed) |
| 53 | ims = [] |
| 54 | for _ in range(n_samples): |
| 55 | img = pipeline.inference(prompt, (1, H, W), neg_prompt, id_embeddings, id_scale, scale, steps)[0] |
| 56 | ims.append(np.array(img)) |
| 57 | |
| 58 | return ims, pipeline.debug_img_list |
| 59 | |
| 60 | |
| 61 | _HEADER_ = ''' |
nothing calls this directly
no test coverage detected