Skip to content

Commit 2fbf245

Browse files
author
Lincoln Stein
committed
Merge branch 'main' into release/invokeai-3-0-beta
-- this adds the upscaling support
2 parents 39c14eb + c89fa4b commit 2fbf245

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+678
-1126
lines changed

invokeai/app/invocations/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ class ImageScaleInvocation(BaseInvocation, PILInvocationConfig):
518518
type: Literal["img_scale"] = "img_scale"
519519

520520
# Inputs
521-
image: Optional[ImageField] = Field(default=None, description="The image to scale")
522-
scale_factor: float = Field(gt=0, description="The factor by which to scale the image")
521+
image: Optional[ImageField] = Field(default=None, description="The image to scale")
522+
scale_factor: Optional[float] = Field(default=2.0, gt=0, description="The factor by which to scale the image")
523523
resample_mode: PIL_RESAMPLING_MODES = Field(default="bicubic", description="The resampling mode")
524524
# fmt: on
525525

invokeai/app/invocations/upscale.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Copyright (c) 2022 Kyle Schouviller (https://github.com/kyle0654) & the InvokeAI Team
2-
from pathlib import Path, PosixPath
3-
from typing import Literal, Union, cast
2+
from pathlib import Path
3+
from typing import Literal, Union
44

55
import cv2 as cv
66
import numpy as np
@@ -16,19 +16,20 @@
1616

1717
# TODO: Populate this from disk?
1818
# TODO: Use model manager to load?
19-
REALESRGAN_MODELS = Literal[
19+
ESRGAN_MODELS = Literal[
2020
"RealESRGAN_x4plus.pth",
2121
"RealESRGAN_x4plus_anime_6B.pth",
2222
"ESRGAN_SRx4_DF2KOST_official-ff704c30.pth",
23+
"RealESRGAN_x2plus.pth",
2324
]
2425

2526

26-
class RealESRGANInvocation(BaseInvocation):
27+
class ESRGANInvocation(BaseInvocation):
2728
"""Upscales an image using RealESRGAN."""
2829

29-
type: Literal["realesrgan"] = "realesrgan"
30+
type: Literal["esrgan"] = "esrgan"
3031
image: Union[ImageField, None] = Field(default=None, description="The input image")
31-
model_name: REALESRGAN_MODELS = Field(
32+
model_name: ESRGAN_MODELS = Field(
3233
default="RealESRGAN_x4plus.pth", description="The Real-ESRGAN model to use"
3334
)
3435

@@ -73,19 +74,17 @@ def invoke(self, context: InvocationContext) -> ImageOutput:
7374
scale=4,
7475
)
7576
netscale = 4
76-
# TODO: add x2 models handling?
77-
# elif self.model_name in ["RealESRGAN_x2plus"]:
78-
# # x2 RRDBNet model
79-
# model = RRDBNet(
80-
# num_in_ch=3,
81-
# num_out_ch=3,
82-
# num_feat=64,
83-
# num_block=23,
84-
# num_grow_ch=32,
85-
# scale=2,
86-
# )
87-
# model_path = Path()
88-
# netscale = 2
77+
elif self.model_name in ["RealESRGAN_x2plus.pth"]:
78+
# x2 RRDBNet model
79+
rrdbnet_model = RRDBNet(
80+
num_in_ch=3,
81+
num_out_ch=3,
82+
num_feat=64,
83+
num_block=23,
84+
num_grow_ch=32,
85+
scale=2,
86+
)
87+
netscale = 2
8988
else:
9089
msg = f"Invalid RealESRGAN model: {self.model_name}"
9190
context.services.logger.error(msg)

invokeai/backend/install/invokeai_configure.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def download_conversion_models():
222222

223223
# ---------------------------------------------
224224
def download_realesrgan():
225-
logger.info("Installing RealESRGAN models...")
225+
logger.info("Installing ESRGAN Upscaling models...")
226226
URLs = [
227227
dict(
228228
url = "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth",
@@ -239,6 +239,11 @@ def download_realesrgan():
239239
dest= "core/upscaling/realesrgan/ESRGAN_SRx4_DF2KOST_official-ff704c30.pth",
240240
description = "ESRGAN_SRx4_DF2KOST_official.pth",
241241
),
242+
dict(
243+
url= "https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth",
244+
dest= "core/upscaling/realesrgan/RealESRGAN_x2plus.pth",
245+
description = "RealESRGAN_x2plus.pth",
246+
),
242247
]
243248
for model in URLs:
244249
download_with_progress_bar(model['url'], config.models_path / model['dest'], model['description'])

invokeai/frontend/web/dist/assets/App-891779fc.js

Lines changed: 0 additions & 169 deletions
This file was deleted.

invokeai/frontend/web/dist/assets/App-9c3ea767.js

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

invokeai/frontend/web/dist/assets/MantineProvider-f3412ed4.js renamed to invokeai/frontend/web/dist/assets/MantineProvider-bb0be923.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

invokeai/frontend/web/dist/assets/ThemeLocaleProvider-617a0567.js renamed to invokeai/frontend/web/dist/assets/ThemeLocaleProvider-529591b4.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

invokeai/frontend/web/dist/assets/index-adc79457.js

Lines changed: 125 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

invokeai/frontend/web/dist/assets/index-c1428e4e.js

Lines changed: 0 additions & 125 deletions
This file was deleted.

invokeai/frontend/web/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
margin: 0;
1313
}
1414
</style>
15-
<script type="module" crossorigin src="./assets/index-c1428e4e.js"></script>
15+
<script type="module" crossorigin src="./assets/index-adc79457.js"></script>
1616
</head>
1717

1818
<body dir="ltr">

0 commit comments

Comments
 (0)