1
0
Fork 0

fix(api): continue converting other models after an error in one (#166)

This commit is contained in:
Sean Sube 2023-02-17 07:49:45 -06:00
parent b3c8fce16b
commit c74d22aa42
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 39 additions and 25 deletions

View File

@ -194,8 +194,12 @@ def convert_models(ctx: ConversionContext, args, models: Models):
else: else:
model_format = source_format(model) model_format = source_format(model)
source = model["source"] source = model["source"]
try:
dest = fetch_model(ctx, name, source, model_format=model_format) dest = fetch_model(ctx, name, source, model_format=model_format)
logger.info("finished downloading source: %s -> %s", source, dest) logger.info("finished downloading source: %s -> %s", source, dest)
except Exception as e:
logger.error("error fetching source %s: %s", name, e)
if args.diffusion and "diffusion" in models: if args.diffusion and "diffusion" in models:
for model in models.get("diffusion"): for model in models.get("diffusion"):
@ -206,6 +210,8 @@ def convert_models(ctx: ConversionContext, args, models: Models):
logger.info("skipping model: %s", name) logger.info("skipping model: %s", name)
else: else:
model_format = source_format(model) model_format = source_format(model)
try:
source = fetch_model( source = fetch_model(
ctx, name, model["source"], model_format=model_format ctx, name, model["source"], model_format=model_format
) )
@ -222,6 +228,8 @@ def convert_models(ctx: ConversionContext, args, models: Models):
model, model,
source, source,
) )
except Exception as e:
logger.error("error converting diffusion model %s: %s", name, e)
if args.upscaling and "upscaling" in models: if args.upscaling and "upscaling" in models:
for model in models.get("upscaling"): for model in models.get("upscaling"):
@ -232,10 +240,14 @@ def convert_models(ctx: ConversionContext, args, models: Models):
logger.info("skipping model: %s", name) logger.info("skipping model: %s", name)
else: else:
model_format = source_format(model) model_format = source_format(model)
try:
source = fetch_model( source = fetch_model(
ctx, name, model["source"], model_format=model_format ctx, name, model["source"], model_format=model_format
) )
convert_upscale_resrgan(ctx, model, source) convert_upscale_resrgan(ctx, model, source)
except Exception as e:
logger.error("error converting upscaling model %s: %s", name, e)
if args.correction and "correction" in models: if args.correction and "correction" in models:
for model in models.get("correction"): for model in models.get("correction"):
@ -246,11 +258,13 @@ def convert_models(ctx: ConversionContext, args, models: Models):
logger.info("skipping model: %s", name) logger.info("skipping model: %s", name)
else: else:
model_format = source_format(model) model_format = source_format(model)
try:
source = fetch_model( source = fetch_model(
ctx, name, model["source"], model_format=model_format ctx, name, model["source"], model_format=model_format
) )
convert_correction_gfpgan(ctx, model, source) convert_correction_gfpgan(ctx, model, source)
except Exception as e:
logger.error("error converting correction model %s: %s", name, e)
def main() -> int: def main() -> int:
parser = ArgumentParser( parser = ArgumentParser(