mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'development' into patch-1
This commit is contained in:
commit
b512d198f0
@ -27,10 +27,25 @@ rm ${PIP_LOG}
|
|||||||
|
|
||||||
**SOLUTION**
|
**SOLUTION**
|
||||||
|
|
||||||
Enter the stable-diffusion directory and completely remove the `src` directory and all its contents.
|
Conda sometimes gets stuck at the last PIP step, in which several git repositories are
|
||||||
The safest way to do this is to enter the stable-diffusion directory and give the command
|
cloned and built.
|
||||||
`git clean -f`. If this still doesn't fix the problem, try "conda clean -all" and then restart at
|
|
||||||
the `conda env create` step.
|
Enter the stable-diffusion directory and completely remove the `src`
|
||||||
|
directory and all its contents. The safest way to do this is to enter
|
||||||
|
the stable-diffusion directory and give the command `git clean -f`. If
|
||||||
|
this still doesn't fix the problem, try "conda clean -all" and then
|
||||||
|
restart at the `conda env create` step.
|
||||||
|
|
||||||
|
To further understand the problem to checking the install lot using this method:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export PIP_LOG="/tmp/pip_log.txt"
|
||||||
|
touch ${PIP_LOG}
|
||||||
|
tail -f ${PIP_LOG} &
|
||||||
|
conda env create -f environment-mac.yaml --debug --verbose
|
||||||
|
killall tail
|
||||||
|
rm ${PIP_LOG}
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ ln -s "$PATH_TO_CKPT/sd-v1-4.ckpt" \
|
|||||||
=== "Intel x86_64"
|
=== "Intel x86_64"
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-x86_64 \
|
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-64 \
|
||||||
conda env create \
|
conda env create \
|
||||||
-f environment-mac.yaml \
|
-f environment-mac.yaml \
|
||||||
&& conda activate ldm
|
&& conda activate ldm
|
||||||
|
@ -594,7 +594,7 @@ class Args(object):
|
|||||||
'--upscale',
|
'--upscale',
|
||||||
nargs='+',
|
nargs='+',
|
||||||
type=float,
|
type=float,
|
||||||
help='Scale factor (2, 4) for upscaling final output followed by upscaling strength (0-1.0). If strength not specified, defaults to 0.75',
|
help='Scale factor (1, 2, 3, 4, etc..) for upscaling final output followed by upscaling strength (0-1.0). If strength not specified, defaults to 0.75',
|
||||||
default=None,
|
default=None,
|
||||||
)
|
)
|
||||||
postprocessing_group.add_argument(
|
postprocessing_group.add_argument(
|
||||||
|
@ -4,18 +4,42 @@ and generates with ldm.dream.generator.img2img
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from tqdm import trange
|
||||||
from ldm.dream.generator.base import Generator
|
from PIL import Image
|
||||||
from ldm.models.diffusion.ddim import DDIMSampler
|
from ldm.dream.generator.base import Generator
|
||||||
from ldm.dream.generator.img2img import Img2Img
|
from ldm.dream.generator.img2img import Img2Img
|
||||||
|
from ldm.dream.devices import choose_autocast
|
||||||
|
|
||||||
class Embiggen(Generator):
|
class Embiggen(Generator):
|
||||||
def __init__(self, model, precision):
|
def __init__(self, model, precision):
|
||||||
super().__init__(model, precision)
|
super().__init__(model, precision)
|
||||||
self.init_latent = None
|
self.init_latent = None
|
||||||
|
|
||||||
|
# Replace generate because Embiggen doesn't need/use most of what it does normallly
|
||||||
|
def generate(self,prompt,iterations=1,seed=None,
|
||||||
|
image_callback=None, step_callback=None,
|
||||||
|
**kwargs):
|
||||||
|
scope = choose_autocast(self.precision)
|
||||||
|
make_image = self.get_make_image(
|
||||||
|
prompt,
|
||||||
|
step_callback = step_callback,
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
results = []
|
||||||
|
seed = seed if seed else self.new_seed()
|
||||||
|
|
||||||
|
# Noise will be generated by the Img2Img generator when called
|
||||||
|
with scope(self.model.device.type), self.model.ema_scope():
|
||||||
|
for n in trange(iterations, desc='Generating'):
|
||||||
|
# make_image will call Img2Img which will do the equivalent of get_noise itself
|
||||||
|
image = make_image()
|
||||||
|
results.append([image, seed])
|
||||||
|
if image_callback is not None:
|
||||||
|
image_callback(image, seed)
|
||||||
|
seed = self.new_seed()
|
||||||
|
return results
|
||||||
|
|
||||||
@torch.no_grad()
|
@torch.no_grad()
|
||||||
def get_make_image(
|
def get_make_image(
|
||||||
self,
|
self,
|
||||||
@ -151,8 +175,19 @@ class Embiggen(Generator):
|
|||||||
# Clamp values to max 255
|
# Clamp values to max 255
|
||||||
if distanceToLR > 255:
|
if distanceToLR > 255:
|
||||||
distanceToLR = 255
|
distanceToLR = 255
|
||||||
# Place the pixel as invert of distance
|
#Place the pixel as invert of distance
|
||||||
agradientC.putpixel((x, y), int(255 - distanceToLR))
|
agradientC.putpixel((x, y), round(255 - distanceToLR))
|
||||||
|
|
||||||
|
# Create alternative asymmetric diagonal corner to use on "tailing" intersections to prevent hard edges
|
||||||
|
# Fits for a left-fading gradient on the bottom side and full opacity on the right side.
|
||||||
|
agradientAsymC = Image.new('L', (256, 256))
|
||||||
|
for y in range(256):
|
||||||
|
for x in range(256):
|
||||||
|
value = round(max(0, x-(255-y)) * (255 / max(1,y)))
|
||||||
|
#Clamp values
|
||||||
|
value = max(0, value)
|
||||||
|
value = min(255, value)
|
||||||
|
agradientAsymC.putpixel((x, y), value)
|
||||||
|
|
||||||
# Create alpha layers default fully white
|
# Create alpha layers default fully white
|
||||||
alphaLayerL = Image.new("L", (width, height), 255)
|
alphaLayerL = Image.new("L", (width, height), 255)
|
||||||
@ -163,8 +198,13 @@ class Embiggen(Generator):
|
|||||||
alphaLayerT.paste(agradientT, (0, 0))
|
alphaLayerT.paste(agradientT, (0, 0))
|
||||||
alphaLayerLTC.paste(agradientL, (0, 0))
|
alphaLayerLTC.paste(agradientL, (0, 0))
|
||||||
alphaLayerLTC.paste(agradientT, (0, 0))
|
alphaLayerLTC.paste(agradientT, (0, 0))
|
||||||
alphaLayerLTC.paste(agradientC.resize(
|
alphaLayerLTC.paste(agradientC.resize((overlap_size_x, overlap_size_y)), (0, 0))
|
||||||
(overlap_size_x, overlap_size_y)), (0, 0))
|
# make masks with an asymmetric upper-right corner so when the curved transparent corner of the next tile
|
||||||
|
# to its right is placed it doesn't reveal a hard trailing semi-transparent edge in the overlapping space
|
||||||
|
alphaLayerTaC = alphaLayerT.copy()
|
||||||
|
alphaLayerTaC.paste(agradientAsymC.rotate(270).resize((overlap_size_x, overlap_size_y)), (width - overlap_size_x, 0))
|
||||||
|
alphaLayerLTaC = alphaLayerLTC.copy()
|
||||||
|
alphaLayerLTaC.paste(agradientAsymC.rotate(270).resize((overlap_size_x, overlap_size_y)), (width - overlap_size_x, 0))
|
||||||
|
|
||||||
if embiggen_tiles:
|
if embiggen_tiles:
|
||||||
# Individual unconnected sides
|
# Individual unconnected sides
|
||||||
@ -242,7 +282,7 @@ class Embiggen(Generator):
|
|||||||
del agradientT
|
del agradientT
|
||||||
del agradientC
|
del agradientC
|
||||||
|
|
||||||
def make_image(x_T):
|
def make_image():
|
||||||
# Make main tiles -------------------------------------------------
|
# Make main tiles -------------------------------------------------
|
||||||
if embiggen_tiles:
|
if embiggen_tiles:
|
||||||
print(f'>> Making {len(embiggen_tiles)} Embiggen tiles...')
|
print(f'>> Making {len(embiggen_tiles)} Embiggen tiles...')
|
||||||
@ -251,7 +291,20 @@ class Embiggen(Generator):
|
|||||||
f'>> Making {(emb_tiles_x * emb_tiles_y)} Embiggen tiles ({emb_tiles_x}x{emb_tiles_y})...')
|
f'>> Making {(emb_tiles_x * emb_tiles_y)} Embiggen tiles ({emb_tiles_x}x{emb_tiles_y})...')
|
||||||
|
|
||||||
emb_tile_store = []
|
emb_tile_store = []
|
||||||
|
# Although we could use the same seed for every tile for determinism, at higher strengths this may
|
||||||
|
# produce duplicated structures for each tile and make the tiling effect more obvious
|
||||||
|
# instead track and iterate a local seed we pass to Img2Img
|
||||||
|
seed = self.seed
|
||||||
|
seedintlimit = np.iinfo(np.uint32).max - 1 # only retreive this one from numpy
|
||||||
|
|
||||||
for tile in range(emb_tiles_x * emb_tiles_y):
|
for tile in range(emb_tiles_x * emb_tiles_y):
|
||||||
|
# Don't iterate on first tile
|
||||||
|
if tile != 0:
|
||||||
|
if seed < seedintlimit:
|
||||||
|
seed += 1
|
||||||
|
else:
|
||||||
|
seed = 0
|
||||||
|
|
||||||
# Determine if this is a re-run and replace
|
# Determine if this is a re-run and replace
|
||||||
if embiggen_tiles and not tile in embiggen_tiles:
|
if embiggen_tiles and not tile in embiggen_tiles:
|
||||||
continue
|
continue
|
||||||
@ -294,21 +347,20 @@ class Embiggen(Generator):
|
|||||||
|
|
||||||
tile_results = gen_img2img.generate(
|
tile_results = gen_img2img.generate(
|
||||||
prompt,
|
prompt,
|
||||||
iterations=1,
|
iterations = 1,
|
||||||
seed=self.seed,
|
seed = seed,
|
||||||
sampler=sampler,
|
sampler = sampler,
|
||||||
steps=steps,
|
steps = steps,
|
||||||
cfg_scale=cfg_scale,
|
cfg_scale = cfg_scale,
|
||||||
conditioning=conditioning,
|
conditioning = conditioning,
|
||||||
ddim_eta=ddim_eta,
|
ddim_eta = ddim_eta,
|
||||||
image_callback=None, # called only after the final image is generated
|
image_callback = None, # called only after the final image is generated
|
||||||
step_callback=step_callback, # called after each intermediate image is generated
|
step_callback = step_callback, # called after each intermediate image is generated
|
||||||
width=width,
|
width = width,
|
||||||
height=height,
|
height = height,
|
||||||
init_img=init_img, # img2img doesn't need this, but it might in the future
|
init_image = newinitimage, # notice that init_image is different from init_img
|
||||||
init_image=newinitimage, # notice that init_image is different from init_img
|
mask_image = None,
|
||||||
mask_image=None,
|
strength = strength,
|
||||||
strength=strength,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
emb_tile_store.append(tile_results[0][0])
|
emb_tile_store.append(tile_results[0][0])
|
||||||
@ -381,24 +433,24 @@ class Embiggen(Generator):
|
|||||||
# bottom of image
|
# bottom of image
|
||||||
elif emb_row_i == emb_tiles_y - 1:
|
elif emb_row_i == emb_tiles_y - 1:
|
||||||
if emb_column_i == 0:
|
if emb_column_i == 0:
|
||||||
if (tile+1) in embiggen_tiles: # Look-ahead right
|
if (tile+1) in embiggen_tiles: # Look-ahead right
|
||||||
intileimage.putalpha(alphaLayerT)
|
intileimage.putalpha(alphaLayerTaC)
|
||||||
else:
|
else:
|
||||||
intileimage.putalpha(alphaLayerRTC)
|
intileimage.putalpha(alphaLayerRTC)
|
||||||
elif emb_column_i == emb_tiles_x - 1:
|
elif emb_column_i == emb_tiles_x - 1:
|
||||||
# No tiles to look ahead to
|
# No tiles to look ahead to
|
||||||
intileimage.putalpha(alphaLayerLTC)
|
intileimage.putalpha(alphaLayerLTC)
|
||||||
else:
|
else:
|
||||||
if (tile+1) in embiggen_tiles: # Look-ahead right
|
if (tile+1) in embiggen_tiles: # Look-ahead right
|
||||||
intileimage.putalpha(alphaLayerLTC)
|
intileimage.putalpha(alphaLayerLTaC)
|
||||||
else:
|
else:
|
||||||
intileimage.putalpha(alphaLayerABB)
|
intileimage.putalpha(alphaLayerABB)
|
||||||
# vertical middle of image
|
# vertical middle of image
|
||||||
else:
|
else:
|
||||||
if emb_column_i == 0:
|
if emb_column_i == 0:
|
||||||
if (tile+1) in embiggen_tiles: # Look-ahead right
|
if (tile+1) in embiggen_tiles: # Look-ahead right
|
||||||
if (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down
|
if (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down
|
||||||
intileimage.putalpha(alphaLayerT)
|
intileimage.putalpha(alphaLayerTaC)
|
||||||
else:
|
else:
|
||||||
intileimage.putalpha(alphaLayerTB)
|
intileimage.putalpha(alphaLayerTB)
|
||||||
elif (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down only
|
elif (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down only
|
||||||
@ -411,9 +463,9 @@ class Embiggen(Generator):
|
|||||||
else:
|
else:
|
||||||
intileimage.putalpha(alphaLayerABR)
|
intileimage.putalpha(alphaLayerABR)
|
||||||
else:
|
else:
|
||||||
if (tile+1) in embiggen_tiles: # Look-ahead right
|
if (tile+1) in embiggen_tiles: # Look-ahead right
|
||||||
if (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down
|
if (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down
|
||||||
intileimage.putalpha(alphaLayerLTC)
|
intileimage.putalpha(alphaLayerLTaC)
|
||||||
else:
|
else:
|
||||||
intileimage.putalpha(alphaLayerABR)
|
intileimage.putalpha(alphaLayerABR)
|
||||||
elif (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down only
|
elif (tile+emb_tiles_x) in embiggen_tiles: # Look-ahead down only
|
||||||
@ -425,9 +477,15 @@ class Embiggen(Generator):
|
|||||||
if emb_row_i == 0 and emb_column_i >= 1:
|
if emb_row_i == 0 and emb_column_i >= 1:
|
||||||
intileimage.putalpha(alphaLayerL)
|
intileimage.putalpha(alphaLayerL)
|
||||||
elif emb_row_i >= 1 and emb_column_i == 0:
|
elif emb_row_i >= 1 and emb_column_i == 0:
|
||||||
intileimage.putalpha(alphaLayerT)
|
if emb_column_i + 1 == emb_tiles_x: # If we don't have anything that can be placed to the right
|
||||||
|
intileimage.putalpha(alphaLayerT)
|
||||||
|
else:
|
||||||
|
intileimage.putalpha(alphaLayerTaC)
|
||||||
else:
|
else:
|
||||||
intileimage.putalpha(alphaLayerLTC)
|
if emb_column_i + 1 == emb_tiles_x: # If we don't have anything that can be placed to the right
|
||||||
|
intileimage.putalpha(alphaLayerLTC)
|
||||||
|
else:
|
||||||
|
intileimage.putalpha(alphaLayerLTaC)
|
||||||
# Layer tile onto final image
|
# Layer tile onto final image
|
||||||
outputsuperimage.alpha_composite(intileimage, (left, top))
|
outputsuperimage.alpha_composite(intileimage, (left, top))
|
||||||
else:
|
else:
|
||||||
|
@ -14,73 +14,53 @@ class ESRGAN():
|
|||||||
else:
|
else:
|
||||||
use_half_precision = True
|
use_half_precision = True
|
||||||
|
|
||||||
def load_esrgan_bg_upsampler(self, upsampler_scale):
|
def load_esrgan_bg_upsampler(self):
|
||||||
if not torch.cuda.is_available(): # CPU or MPS on M1
|
if not torch.cuda.is_available(): # CPU or MPS on M1
|
||||||
use_half_precision = False
|
use_half_precision = False
|
||||||
else:
|
else:
|
||||||
use_half_precision = True
|
use_half_precision = True
|
||||||
|
|
||||||
model_path = {
|
from realesrgan.archs.srvgg_arch import SRVGGNetCompact
|
||||||
2: 'https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth',
|
from realesrgan import RealESRGANer
|
||||||
4: 'https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth',
|
|
||||||
}
|
|
||||||
|
|
||||||
if upsampler_scale not in model_path:
|
model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu')
|
||||||
return None
|
model_path = 'https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth'
|
||||||
else:
|
scale = 4
|
||||||
from basicsr.archs.rrdbnet_arch import RRDBNet
|
|
||||||
from realesrgan import RealESRGANer
|
|
||||||
|
|
||||||
if upsampler_scale == 4:
|
bg_upsampler = RealESRGANer(
|
||||||
model = RRDBNet(
|
scale=scale,
|
||||||
num_in_ch=3,
|
model_path=model_path,
|
||||||
num_out_ch=3,
|
model=model,
|
||||||
num_feat=64,
|
tile=self.bg_tile_size,
|
||||||
num_block=23,
|
tile_pad=10,
|
||||||
num_grow_ch=32,
|
pre_pad=0,
|
||||||
scale=4,
|
half=use_half_precision,
|
||||||
)
|
)
|
||||||
if upsampler_scale == 2:
|
|
||||||
model = RRDBNet(
|
|
||||||
num_in_ch=3,
|
|
||||||
num_out_ch=3,
|
|
||||||
num_feat=64,
|
|
||||||
num_block=23,
|
|
||||||
num_grow_ch=32,
|
|
||||||
scale=2,
|
|
||||||
)
|
|
||||||
|
|
||||||
bg_upsampler = RealESRGANer(
|
|
||||||
scale=upsampler_scale,
|
|
||||||
model_path=model_path[upsampler_scale],
|
|
||||||
model=model,
|
|
||||||
tile=self.bg_tile_size,
|
|
||||||
tile_pad=10,
|
|
||||||
pre_pad=0,
|
|
||||||
half=use_half_precision,
|
|
||||||
)
|
|
||||||
|
|
||||||
return bg_upsampler
|
return bg_upsampler
|
||||||
|
|
||||||
def process(self, image, strength: float, seed: str = None, upsampler_scale: int = 2):
|
def process(self, image, strength: float, seed: str = None, upsampler_scale: int = 2):
|
||||||
if seed is not None:
|
|
||||||
print(
|
|
||||||
f'>> Real-ESRGAN Upscaling seed:{seed} : scale:{upsampler_scale}x'
|
|
||||||
)
|
|
||||||
|
|
||||||
with warnings.catch_warnings():
|
with warnings.catch_warnings():
|
||||||
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
||||||
warnings.filterwarnings('ignore', category=UserWarning)
|
warnings.filterwarnings('ignore', category=UserWarning)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
upsampler = self.load_esrgan_bg_upsampler(upsampler_scale)
|
upsampler = self.load_esrgan_bg_upsampler()
|
||||||
except Exception:
|
except Exception:
|
||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
print('>> Error loading Real-ESRGAN:', file=sys.stderr)
|
print('>> Error loading Real-ESRGAN:', file=sys.stderr)
|
||||||
print(traceback.format_exc(), file=sys.stderr)
|
print(traceback.format_exc(), file=sys.stderr)
|
||||||
|
|
||||||
|
if upsampler_scale == 0:
|
||||||
|
print('>> Real-ESRGAN: Invalid scaling option. Image not upscaled.')
|
||||||
|
return image
|
||||||
|
|
||||||
|
if seed is not None:
|
||||||
|
print(
|
||||||
|
f'>> Real-ESRGAN Upscaling seed:{seed} : scale:{upsampler_scale}x'
|
||||||
|
)
|
||||||
|
|
||||||
output, _ = upsampler.enhance(
|
output, _ = upsampler.enhance(
|
||||||
np.array(image, dtype=np.uint8),
|
np.array(image, dtype=np.uint8),
|
||||||
outscale=upsampler_scale,
|
outscale=upsampler_scale,
|
||||||
|
@ -497,11 +497,8 @@ class Generate:
|
|||||||
prompt = None
|
prompt = None
|
||||||
try:
|
try:
|
||||||
args = metadata_from_png(image_path)
|
args = metadata_from_png(image_path)
|
||||||
if len(args) > 1:
|
seed = args.seed
|
||||||
print("* Can't postprocess a grid")
|
prompt = args.prompt
|
||||||
return
|
|
||||||
seed = args[0].seed
|
|
||||||
prompt = args[0].prompt
|
|
||||||
print(f'>> retrieved seed {seed} and prompt "{prompt}" from {image_path}')
|
print(f'>> retrieved seed {seed} and prompt "{prompt}" from {image_path}')
|
||||||
except:
|
except:
|
||||||
m = re.search('(\d+)\.png$',image_path)
|
m = re.search('(\d+)\.png$',image_path)
|
||||||
@ -724,14 +721,6 @@ class Generate:
|
|||||||
for r in image_list:
|
for r in image_list:
|
||||||
image, seed = r
|
image, seed = r
|
||||||
try:
|
try:
|
||||||
if upscale is not None:
|
|
||||||
if self.esrgan is not None:
|
|
||||||
if len(upscale) < 2:
|
|
||||||
upscale.append(0.75)
|
|
||||||
image = self.esrgan.process(
|
|
||||||
image, upscale[1], seed, int(upscale[0]))
|
|
||||||
else:
|
|
||||||
print(">> ESRGAN is disabled. Image not upscaled.")
|
|
||||||
if strength > 0:
|
if strength > 0:
|
||||||
if self.gfpgan is not None or self.codeformer is not None:
|
if self.gfpgan is not None or self.codeformer is not None:
|
||||||
if facetool == 'gfpgan':
|
if facetool == 'gfpgan':
|
||||||
@ -747,6 +736,14 @@ class Generate:
|
|||||||
image = self.codeformer.process(image=image, strength=strength, device=cf_device, seed=seed, fidelity=codeformer_fidelity)
|
image = self.codeformer.process(image=image, strength=strength, device=cf_device, seed=seed, fidelity=codeformer_fidelity)
|
||||||
else:
|
else:
|
||||||
print(">> Face Restoration is disabled.")
|
print(">> Face Restoration is disabled.")
|
||||||
|
if upscale is not None:
|
||||||
|
if self.esrgan is not None:
|
||||||
|
if len(upscale) < 2:
|
||||||
|
upscale.append(0.75)
|
||||||
|
image = self.esrgan.process(
|
||||||
|
image, upscale[1], seed, int(upscale[0]))
|
||||||
|
else:
|
||||||
|
print(">> ESRGAN is disabled. Image not upscaled.")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(
|
print(
|
||||||
f'>> Error running RealESRGAN or GFPGAN. Your image was not upscaled.\n{e}'
|
f'>> Error running RealESRGAN or GFPGAN. Your image was not upscaled.\n{e}'
|
||||||
|
@ -49,33 +49,13 @@ except ModuleNotFoundError:
|
|||||||
if gfpgan:
|
if gfpgan:
|
||||||
print('Loading models from RealESRGAN and facexlib')
|
print('Loading models from RealESRGAN and facexlib')
|
||||||
try:
|
try:
|
||||||
from basicsr.archs.rrdbnet_arch import RRDBNet
|
from realesrgan.archs.srvgg_arch import SRVGGNetCompact
|
||||||
from facexlib.utils.face_restoration_helper import FaceRestoreHelper
|
from facexlib.utils.face_restoration_helper import FaceRestoreHelper
|
||||||
|
|
||||||
RealESRGANer(
|
|
||||||
scale=2,
|
|
||||||
model_path='https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth',
|
|
||||||
model=RRDBNet(
|
|
||||||
num_in_ch=3,
|
|
||||||
num_out_ch=3,
|
|
||||||
num_feat=64,
|
|
||||||
num_block=23,
|
|
||||||
num_grow_ch=32,
|
|
||||||
scale=2,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
RealESRGANer(
|
RealESRGANer(
|
||||||
scale=4,
|
scale=4,
|
||||||
model_path='https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth',
|
model_path='https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.5.0/realesr-general-x4v3.pth',
|
||||||
model=RRDBNet(
|
model = SRVGGNetCompact(num_in_ch=3, num_out_ch=3, num_feat=64, num_conv=32, upscale=4, act_type='prelu')
|
||||||
num_in_ch=3,
|
|
||||||
num_out_ch=3,
|
|
||||||
num_feat=64,
|
|
||||||
num_block=23,
|
|
||||||
num_grow_ch=32,
|
|
||||||
scale=4,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
FaceRestoreHelper(1, det_model='retinaface_resnet50')
|
FaceRestoreHelper(1, det_model='retinaface_resnet50')
|
||||||
|
Loading…
Reference in New Issue
Block a user