Pārlūkot izejas kodu

manual fixes for some C408

AUTOMATIC 2 gadi atpakaļ
vecāks
revīzija
d25219b7e8

+ 2 - 2
extensions-builtin/LDSR/ldsr_model_arch.py

@@ -157,7 +157,7 @@ class LDSR:
 
 
 
 
 def get_cond(selected_path):
 def get_cond(selected_path):
-    example = dict()
+    example = {}
     up_f = 4
     up_f = 4
     c = selected_path.convert('RGB')
     c = selected_path.convert('RGB')
     c = torch.unsqueeze(torchvision.transforms.ToTensor()(c), 0)
     c = torch.unsqueeze(torchvision.transforms.ToTensor()(c), 0)
@@ -195,7 +195,7 @@ def convsample_ddim(model, cond, steps, shape, eta=1.0, callback=None, normals_s
 @torch.no_grad()
 @torch.no_grad()
 def make_convolutional_sample(batch, model, custom_steps=None, eta=1.0, quantize_x0=False, custom_shape=None, temperature=1., noise_dropout=0., corrector=None,
 def make_convolutional_sample(batch, model, custom_steps=None, eta=1.0, quantize_x0=False, custom_shape=None, temperature=1., noise_dropout=0., corrector=None,
                               corrector_kwargs=None, x_T=None, ddim_use_x0_pred=False):
                               corrector_kwargs=None, x_T=None, ddim_use_x0_pred=False):
-    log = dict()
+    log = {}
 
 
     z, c, x, xrec, xc = model.get_input(batch, model.first_stage_key,
     z, c, x, xrec, xc = model.get_input(batch, model.first_stage_key,
                                         return_first_stage_outputs=True,
                                         return_first_stage_outputs=True,

+ 1 - 1
extensions-builtin/LDSR/sd_hijack_autoencoder.py

@@ -237,7 +237,7 @@ class VQModel(pl.LightningModule):
         return self.decoder.conv_out.weight
         return self.decoder.conv_out.weight
 
 
     def log_images(self, batch, only_inputs=False, plot_ema=False, **kwargs):
     def log_images(self, batch, only_inputs=False, plot_ema=False, **kwargs):
-        log = dict()
+        log = {}
         x = self.get_input(batch, self.image_key)
         x = self.get_input(batch, self.image_key)
         x = x.to(self.device)
         x = x.to(self.device)
         if only_inputs:
         if only_inputs:

+ 4 - 4
extensions-builtin/LDSR/sd_hijack_ddpm_v1.py

@@ -375,7 +375,7 @@ class DDPMV1(pl.LightningModule):
 
 
     @torch.no_grad()
     @torch.no_grad()
     def log_images(self, batch, N=8, n_row=2, sample=True, return_keys=None, **kwargs):
     def log_images(self, batch, N=8, n_row=2, sample=True, return_keys=None, **kwargs):
-        log = dict()
+        log = {}
         x = self.get_input(batch, self.first_stage_key)
         x = self.get_input(batch, self.first_stage_key)
         N = min(x.shape[0], N)
         N = min(x.shape[0], N)
         n_row = min(x.shape[0], n_row)
         n_row = min(x.shape[0], n_row)
@@ -383,7 +383,7 @@ class DDPMV1(pl.LightningModule):
         log["inputs"] = x
         log["inputs"] = x
 
 
         # get diffusion row
         # get diffusion row
-        diffusion_row = list()
+        diffusion_row = []
         x_start = x[:n_row]
         x_start = x[:n_row]
 
 
         for t in range(self.num_timesteps):
         for t in range(self.num_timesteps):
@@ -1247,7 +1247,7 @@ class LatentDiffusionV1(DDPMV1):
 
 
         use_ddim = ddim_steps is not None
         use_ddim = ddim_steps is not None
 
 
-        log = dict()
+        log = {}
         z, c, x, xrec, xc = self.get_input(batch, self.first_stage_key,
         z, c, x, xrec, xc = self.get_input(batch, self.first_stage_key,
                                            return_first_stage_outputs=True,
                                            return_first_stage_outputs=True,
                                            force_c_encode=True,
                                            force_c_encode=True,
@@ -1274,7 +1274,7 @@ class LatentDiffusionV1(DDPMV1):
 
 
         if plot_diffusion_rows:
         if plot_diffusion_rows:
             # get diffusion row
             # get diffusion row
-            diffusion_row = list()
+            diffusion_row = []
             z_start = z[:n_row]
             z_start = z[:n_row]
             for t in range(self.num_timesteps):
             for t in range(self.num_timesteps):
                 if t % self.log_every_t == 0 or t == self.num_timesteps - 1:
                 if t % self.log_every_t == 0 or t == self.num_timesteps - 1:

+ 1 - 1
modules/api/api.py

@@ -165,7 +165,7 @@ def api_middleware(app: FastAPI):
 class Api:
 class Api:
     def __init__(self, app: FastAPI, queue_lock: Lock):
     def __init__(self, app: FastAPI, queue_lock: Lock):
         if shared.cmd_opts.api_auth:
         if shared.cmd_opts.api_auth:
-            self.credentials = dict()
+            self.credentials = {}
             for auth in shared.cmd_opts.api_auth.split(","):
             for auth in shared.cmd_opts.api_auth.split(","):
                 user, password = auth.split(":")
                 user, password = auth.split(":")
                 self.credentials[user] = password
                 self.credentials[user] = password

+ 4 - 4
modules/models/diffusion/ddpm_edit.py

@@ -405,7 +405,7 @@ class DDPM(pl.LightningModule):
 
 
     @torch.no_grad()
     @torch.no_grad()
     def log_images(self, batch, N=8, n_row=2, sample=True, return_keys=None, **kwargs):
     def log_images(self, batch, N=8, n_row=2, sample=True, return_keys=None, **kwargs):
-        log = dict()
+        log = {}
         x = self.get_input(batch, self.first_stage_key)
         x = self.get_input(batch, self.first_stage_key)
         N = min(x.shape[0], N)
         N = min(x.shape[0], N)
         n_row = min(x.shape[0], n_row)
         n_row = min(x.shape[0], n_row)
@@ -413,7 +413,7 @@ class DDPM(pl.LightningModule):
         log["inputs"] = x
         log["inputs"] = x
 
 
         # get diffusion row
         # get diffusion row
-        diffusion_row = list()
+        diffusion_row = []
         x_start = x[:n_row]
         x_start = x[:n_row]
 
 
         for t in range(self.num_timesteps):
         for t in range(self.num_timesteps):
@@ -1263,7 +1263,7 @@ class LatentDiffusion(DDPM):
 
 
         use_ddim = False
         use_ddim = False
 
 
-        log = dict()
+        log = {}
         z, c, x, xrec, xc = self.get_input(batch, self.first_stage_key,
         z, c, x, xrec, xc = self.get_input(batch, self.first_stage_key,
                                            return_first_stage_outputs=True,
                                            return_first_stage_outputs=True,
                                            force_c_encode=True,
                                            force_c_encode=True,
@@ -1291,7 +1291,7 @@ class LatentDiffusion(DDPM):
 
 
         if plot_diffusion_rows:
         if plot_diffusion_rows:
             # get diffusion row
             # get diffusion row
-            diffusion_row = list()
+            diffusion_row = []
             z_start = z[:n_row]
             z_start = z[:n_row]
             for t in range(self.num_timesteps):
             for t in range(self.num_timesteps):
                 if t % self.log_every_t == 0 or t == self.num_timesteps - 1:
                 if t % self.log_every_t == 0 or t == self.num_timesteps - 1:

+ 2 - 2
modules/models/diffusion/uni_pc/uni_pc.py

@@ -344,7 +344,7 @@ def model_wrapper(
                 t_in = torch.cat([t_continuous] * 2)
                 t_in = torch.cat([t_continuous] * 2)
                 if isinstance(condition, dict):
                 if isinstance(condition, dict):
                     assert isinstance(unconditional_condition, dict)
                     assert isinstance(unconditional_condition, dict)
-                    c_in = dict()
+                    c_in = {}
                     for k in condition:
                     for k in condition:
                         if isinstance(condition[k], list):
                         if isinstance(condition[k], list):
                             c_in[k] = [torch.cat([
                             c_in[k] = [torch.cat([
@@ -355,7 +355,7 @@ def model_wrapper(
                                 unconditional_condition[k],
                                 unconditional_condition[k],
                                 condition[k]])
                                 condition[k]])
                 elif isinstance(condition, list):
                 elif isinstance(condition, list):
-                    c_in = list()
+                    c_in = []
                     assert isinstance(unconditional_condition, list)
                     assert isinstance(unconditional_condition, list)
                     for i in range(len(condition)):
                     for i in range(len(condition)):
                         c_in.append(torch.cat([unconditional_condition[i], condition[i]]))
                         c_in.append(torch.cat([unconditional_condition[i], condition[i]]))

+ 1 - 1
modules/sd_hijack_inpainting.py

@@ -23,7 +23,7 @@ def p_sample_plms(self, x, c, t, index, repeat_noise=False, use_original_steps=F
 
 
             if isinstance(c, dict):
             if isinstance(c, dict):
                 assert isinstance(unconditional_conditioning, dict)
                 assert isinstance(unconditional_conditioning, dict)
-                c_in = dict()
+                c_in = {}
                 for k in c:
                 for k in c:
                     if isinstance(c[k], list):
                     if isinstance(c[k], list):
                         c_in[k] = [
                         c_in[k] = [