(self, conditioning, unconditional_conditioning, seeds, subseeds, subseed_strength, prompts)
| 1334 | # here we don't need to generate image, we just take self.firstpass_image and prepare it for HiRes fix |
| 1335 | if self.latent_scale_mode is None: |
| 1336 | image = np.array(self.firstpass_image).astype(np.float32) / 255.0 * 2.0 - 1.0 |
| 1337 | image = np.moveaxis(image, 2, 0) |
| 1338 | |
| 1339 | samples = None |
| 1340 | decoded_samples = torch.asarray(np.expand_dims(image, 0)) |
| 1341 | else: |
| 1342 | image = np.array(self.firstpass_image).astype(np.float32) / 255.0 |
| 1343 | image = np.moveaxis(image, 2, 0) |
| 1344 | image = torch.from_numpy(np.expand_dims(image, axis=0)) |
| 1345 | image = image.to(shared.device, dtype=torch.float32) |
| 1346 | |
| 1347 | samples = sd_samplers_common.images_tensor_to_samples(image, sd_samplers_common.approximation_indexes.get(opts.sd_vae_encode_method), self.sd_model) |
| 1348 | decoded_samples = None |
| 1349 | devices.torch_gc() |
| 1350 | |
| 1351 | else: |
| 1352 | # here we generate an image normally |
| 1353 | x = self.rng.next() |
| 1354 | |
| 1355 | self.sd_model.forge_objects = self.sd_model.forge_objects_after_applying_lora.shallow_copy() |
| 1356 | sd_models.apply_token_merging(self.sd_model, self.get_token_merging_ratio()) |
| 1357 | |
| 1358 | if self.scripts is not None: |
| 1359 | self.scripts.process_before_every_sampling(self, x=x, noise=x, c=conditioning, uc=unconditional_conditioning) |
| 1360 | |
| 1361 | if self.modified_noise is not None: |
| 1362 | x = self.modified_noise |
| 1363 | self.modified_noise = None |
| 1364 | |
| 1365 | samples = self.sampler.sample(self, x, conditioning, unconditional_conditioning, image_conditioning=self.txt2img_image_conditioning(x)) |
| 1366 | del x |
| 1367 | |
| 1368 | if not self.enable_hr: |
| 1369 | return samples |
| 1370 | |
| 1371 | devices.torch_gc() |
| 1372 | |
| 1373 | if self.latent_scale_mode is None: |
| 1374 | decoded_samples = torch.stack(decode_latent_batch(self.sd_model, samples, target_device=devices.cpu)).to(dtype=torch.float32) |
| 1375 | else: |
| 1376 | decoded_samples = None |
| 1377 | |
| 1378 | # load HiRes model and modules |
| 1379 | fp_checkpoint = getattr(opts, 'sd_model_checkpoint') |
| 1380 | fp_additional_modules = getattr(opts, 'forge_additional_modules') |
| 1381 | |
| 1382 | reload = False |
| 1383 | if self.hr_additional_modules is not None and 'Use same choices' not in self.hr_additional_modules: |
| 1384 | modules_changed = main_entry.modules_change(self.hr_additional_modules, save=False, refresh=False) |
| 1385 | if modules_changed: |
| 1386 | reload = True |
| 1387 | |
| 1388 | if self.hr_checkpoint_name and self.hr_checkpoint_name != 'Use same checkpoint': |
| 1389 | checkpoint_changed = main_entry.checkpoint_change(self.hr_checkpoint_name, save=False, refresh=False) |
| 1390 | if checkpoint_changed: |
| 1391 | self.firstpass_use_distilled_cfg_scale = self.sd_model.use_distilled_cfg_scale |
| 1392 | reload = True |
| 1393 |
nothing calls this directly
no test coverage detected