Skip to content

Commit

Permalink
fixed mono models code indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
qduaty committed Jul 2, 2024
1 parent d4ddcf3 commit 8f49cdd
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions QualityScaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,21 @@ def AI_upscale(
output_image[:,:,2] = numpy.clip(output_imageYCbCr[:,:,0] + 1.772 * (output_imageYCbCr[:,:,1] - 0.5), 0, 1)

else:
imageR = image[:, :, 0]
imageR = numpy_expand_dims(imageR, axis=2)
imageR = preprocess_image(imageR)
output_image = process_image_with_AI_model(AI_model, imageR)
output_image = numpy.repeat(output_image, 3, 2)

imageG = image[:, :, 1]
imageG = numpy_expand_dims(imageG, axis=2)
imageG = preprocess_image(imageG)
output_image[:,:,1] = process_image_with_AI_model(AI_model, imageG).squeeze()

imageB = image[:, :, 2]
imageB = numpy_expand_dims(imageB, axis=2)
imageB = preprocess_image(imageB)
output_image[:,:,2] = process_image_with_AI_model(AI_model, imageB).squeeze()
imageR = image[:, :, 0]
imageR = numpy_expand_dims(imageR, axis=2)
imageR = preprocess_image(imageR)
output_image = process_image_with_AI_model(AI_model, imageR)
output_image = numpy.repeat(output_image, 3, 2)

imageG = image[:, :, 1]
imageG = numpy_expand_dims(imageG, axis=2)
imageG = preprocess_image(imageG)
output_image[:,:,1] = process_image_with_AI_model(AI_model, imageG).squeeze()

imageB = image[:, :, 2]
imageB = numpy_expand_dims(imageB, axis=2)
imageB = preprocess_image(imageB)
output_image[:,:,2] = process_image_with_AI_model(AI_model, imageB).squeeze()

return postprocess_output(output_image, range)

Expand Down Expand Up @@ -348,41 +348,41 @@ def AI_upscale(
output_image = output_image.squeeze()
return postprocess_output(output_image, range)
else:
match image_mode:
case "RGB":
image = preprocess_image(image)
output_image = process_image_with_AI_model(AI_model, image)
return postprocess_output(output_image, range)
case "RGBA":
alpha = image[:, :, 3]
image = image[:, :, :3]
image = opencv_cvtColor(image, COLOR_BGR2RGB)
alpha = opencv_cvtColor(alpha, COLOR_GRAY2RGB)

image = image.astype(float32)
alpha = alpha.astype(float32)

# Image
image = preprocess_image(image)
output_image = process_image_with_AI_model(AI_model, image)
output_image = opencv_cvtColor(output_image, COLOR_RGB2BGRA)

# Alpha
alpha = preprocess_image(alpha)
output_alpha = process_image_with_AI_model(AI_model, alpha)
output_alpha = opencv_cvtColor(output_alpha, COLOR_RGB2GRAY)

# Fusion Image + Alpha
output_image[:, :, 3] = output_alpha
return postprocess_output(output_image, range)
case "Grayscale":
image = opencv_cvtColor(image, COLOR_GRAY2RGB)
image = preprocess_image(image)
output_image = process_image_with_AI_model(AI_model, image)
output_image = opencv_cvtColor(output_image, COLOR_RGB2GRAY)
return postprocess_output(output_image, range)
match image_mode:
case "RGB":
image = preprocess_image(image)
output_image = process_image_with_AI_model(AI_model, image)
return postprocess_output(output_image, range)

case "RGBA":
alpha = image[:, :, 3]
image = image[:, :, :3]
image = opencv_cvtColor(image, COLOR_BGR2RGB)
alpha = opencv_cvtColor(alpha, COLOR_GRAY2RGB)

image = image.astype(float32)
alpha = alpha.astype(float32)

# Image
image = preprocess_image(image)
output_image = process_image_with_AI_model(AI_model, image)
output_image = opencv_cvtColor(output_image, COLOR_RGB2BGRA)

# Alpha
alpha = preprocess_image(alpha)
output_alpha = process_image_with_AI_model(AI_model, alpha)
output_alpha = opencv_cvtColor(output_alpha, COLOR_RGB2GRAY)

# Fusion Image + Alpha
output_image[:, :, 3] = output_alpha
return postprocess_output(output_image, range)

case "Grayscale":
image = opencv_cvtColor(image, COLOR_GRAY2RGB)
image = preprocess_image(image)
output_image = process_image_with_AI_model(AI_model, image)
output_image = opencv_cvtColor(output_image, COLOR_RGB2GRAY)
return postprocess_output(output_image, range)

def get_image_mode(image: numpy_ndarray) -> str:
match image.shape:
Expand Down

0 comments on commit 8f49cdd

Please sign in to comment.