Reformatting

This commit is contained in:
Andres Caicedo 2023-05-08 14:42:53 +02:00
parent a825f77092
commit 462a9d3298
No known key found for this signature in database
GPG key ID: 6E797C4F5A327624
15 changed files with 47 additions and 72 deletions

View file

@ -472,7 +472,6 @@ class DDIMSampler(object):
use_original_steps=False, use_original_steps=False,
callback=None, callback=None,
): ):
timesteps = ( timesteps = (
np.arange(self.ddpm_num_timesteps) np.arange(self.ddpm_num_timesteps)
if use_original_steps if use_original_steps

View file

@ -1358,7 +1358,6 @@ class LatentDiffusion(DDPM):
start_T=None, start_T=None,
log_every_t=None, log_every_t=None,
): ):
if not log_every_t: if not log_every_t:
log_every_t = self.log_every_t log_every_t = self.log_every_t
device = self.betas.device device = self.betas.device

View file

@ -519,7 +519,6 @@ def degradation_bsrgan(img, sf=4, lq_patchsize=72, isp_model=None):
) )
for i in shuffle_order: for i in shuffle_order:
if i == 0: if i == 0:
img = add_blur(img, sf=sf) img = add_blur(img, sf=sf)
@ -623,7 +622,6 @@ def degradation_bsrgan_variant(image, sf=4, isp_model=None):
) )
for i in shuffle_order: for i in shuffle_order:
if i == 0: if i == 0:
image = add_blur(image, sf=sf) image = add_blur(image, sf=sf)

View file

@ -520,7 +520,6 @@ def degradation_bsrgan(img, sf=4, lq_patchsize=72, isp_model=None):
) )
for i in shuffle_order: for i in shuffle_order:
if i == 0: if i == 0:
img = add_blur(img, sf=sf) img = add_blur(img, sf=sf)
@ -624,7 +623,6 @@ def degradation_bsrgan_variant(image, sf=4, isp_model=None, up=False):
) )
for i in shuffle_order: for i in shuffle_order:
if i == 0: if i == 0:
image = add_blur(image, sf=sf) image = add_blur(image, sf=sf)

View file

@ -271,22 +271,18 @@ def read_img(path):
def uint2single(img): def uint2single(img):
return np.float32(img / 255.0) return np.float32(img / 255.0)
def single2uint(img): def single2uint(img):
return np.uint8((img.clip(0, 1) * 255.0).round()) return np.uint8((img.clip(0, 1) * 255.0).round())
def uint162single(img): def uint162single(img):
return np.float32(img / 65535.0) return np.float32(img / 65535.0)
def single2uint16(img): def single2uint16(img):
return np.uint16((img.clip(0, 1) * 65535.0).round()) return np.uint16((img.clip(0, 1) * 65535.0).round())
@ -586,18 +582,14 @@ def rgb2ycbcr(img, only_y=True):
if only_y: if only_y:
rlt = np.dot(img, [65.481, 128.553, 24.966]) / 255.0 + 16.0 rlt = np.dot(img, [65.481, 128.553, 24.966]) / 255.0 + 16.0
else: else:
rlt = ( rlt = np.matmul(
np.matmul(
img, img,
[ [
[65.481, -37.797, 112.0], [65.481, -37.797, 112.0],
[128.553, -74.203, -93.786], [128.553, -74.203, -93.786],
[24.966, 112.0, -18.214], [24.966, 112.0, -18.214],
], ],
) ) / 255.0 + [16, 128, 128]
/ 255.0
+ [16, 128, 128]
)
if in_img_type == np.uint8: if in_img_type == np.uint8:
rlt = rlt.round() rlt = rlt.round()
else: else:
@ -616,18 +608,14 @@ def ycbcr2rgb(img):
if in_img_type != np.uint8: if in_img_type != np.uint8:
img *= 255.0 img *= 255.0
# convert # convert
rlt = ( rlt = np.matmul(
np.matmul(
img, img,
[ [
[0.00456621, 0.00456621, 0.00456621], [0.00456621, 0.00456621, 0.00456621],
[0, -0.00153632, 0.00791071], [0, -0.00153632, 0.00791071],
[0.00625893, -0.00318811, 0], [0.00625893, -0.00318811, 0],
], ],
) ) * 255.0 + [-222.921, 135.576, -276.836]
* 255.0
+ [-222.921, 135.576, -276.836]
)
if in_img_type == np.uint8: if in_img_type == np.uint8:
rlt = rlt.round() rlt = rlt.round()
else: else:
@ -650,18 +638,14 @@ def bgr2ycbcr(img, only_y=True):
if only_y: if only_y:
rlt = np.dot(img, [24.966, 128.553, 65.481]) / 255.0 + 16.0 rlt = np.dot(img, [24.966, 128.553, 65.481]) / 255.0 + 16.0
else: else:
rlt = ( rlt = np.matmul(
np.matmul(
img, img,
[ [
[24.966, 112.0, -18.214], [24.966, 112.0, -18.214],
[128.553, -74.203, -93.786], [128.553, -74.203, -93.786],
[65.481, -37.797, 112.0], [65.481, -37.797, 112.0],
], ],
) ) / 255.0 + [16, 128, 128]
/ 255.0
+ [16, 128, 128]
)
if in_img_type == np.uint8: if in_img_type == np.uint8:
rlt = rlt.round() rlt = rlt.round()
else: else:

View file

@ -36,7 +36,6 @@ class T2ISampler(BaseSampler):
clip_stat_path: str, clip_stat_path: str,
sampling_type: str = "default", sampling_type: str = "default",
): ):
model = cls( model = cls(
root_dir=root_dir, root_dir=root_dir,
sampling_type=sampling_type, sampling_type=sampling_type,

View file

@ -33,7 +33,6 @@ class DPT(BaseModel):
channels_last=False, channels_last=False,
use_bn=False, use_bn=False,
): ):
super(DPT, self).__init__() super(DPT, self).__init__()
self.channels_last = channels_last self.channels_last = channels_last

View file

@ -17,7 +17,6 @@ def read_pfm(path):
tuple: (data, scale) tuple: (data, scale)
""" """
with open(path, "rb") as file: with open(path, "rb") as file:
color = None color = None
width = None width = None
height = None height = None

View file

@ -16,7 +16,7 @@ gradio==3.13.2
kornia==0.6 kornia==0.6
invisible-watermark>=0.1.5 invisible-watermark>=0.1.5
streamlit-drawable-canvas==0.8.0 streamlit-drawable-canvas==0.8.0
black==21.9b0 black==23.3.0
isort==5.9.3 isort==5.9.3
flake8==4.0.1 flake8==4.0.1
click==8.0.3 click==8.0.3