avans06 commited on
Commit
cc44a11
·
1 Parent(s): 8cbd0a5

Added support for parsing MoSR models from the MoSR project by author umzi2.

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -280,6 +280,12 @@ Optimized primarily for PAL resolution (NTSC might work good as well)."""],
280
  "4xNomos2_hq_atd.pth" : ["https://github.com/Phhofm/models/releases/download/4xNomos2_hq_atd/4xNomos2_hq_atd.pth",
281
  "https://github.com/Phhofm/models/releases/tag/4xNomos2_hq_atd",
282
  """An atd 4x upscaling model, similiar to the 4xNomos2_hq_dat2 or 4xNomos2_hq_mosr models, trained and for usage on non-degraded input to give good quality output.
 
 
 
 
 
 
283
  """],
284
  }
285
 
@@ -312,6 +318,8 @@ def get_model_type(model_name):
312
  model_type = "DRCT"
313
  elif "atd" in model_name.lower():
314
  model_type = "ATD"
 
 
315
  return f"{model_type}, {model_name}"
316
 
317
  typed_upscale_models = {get_model_type(key): value[0] for key, value in upscale_models.items()}
@@ -449,6 +457,19 @@ class Upscale:
449
  upsampler=upsampler,
450
  use_checkpoint=False,
451
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
452
 
453
  self.upsampler = None
454
  if model:
@@ -720,7 +741,7 @@ def main():
720
  for key, _ in typed_upscale_models.items():
721
  upscale_type, upscale_model = key.split(", ", 1)
722
  if tmptype and tmptype != upscale_type:#RRDB ESRGAN
723
- speed = "Fast" if tmptype == "SRVGG" else ("Slow" if any(value == tmptype for value in ("DAT", "HAT", "DRCT")) else "Normal")
724
  upscale_model_header = f"| Upscale Model | Info, Type: {tmptype}, Model execution speed: {speed} | Download URL |\n|------------|------|--------------|"
725
  upscale_model_tables.append(upscale_model_header + "\n" + "\n".join(rows))
726
  rows.clear()
@@ -728,6 +749,7 @@ def main():
728
  value = upscale_models[upscale_model]
729
  row = f"| [{upscale_model}]({value[1]}) | " + value[2].replace("\n", "<br>") + " | [download]({value[0]}) |"
730
  rows.append(row)
 
731
  upscale_model_header = f"| Upscale Model Name | Info, Type: {tmptype}, Model execution speed: {speed} | Download URL |\n|------------|------|--------------|"
732
  upscale_model_tables.append(upscale_model_header + "\n" + "\n".join(rows))
733
 
 
280
  "4xNomos2_hq_atd.pth" : ["https://github.com/Phhofm/models/releases/download/4xNomos2_hq_atd/4xNomos2_hq_atd.pth",
281
  "https://github.com/Phhofm/models/releases/tag/4xNomos2_hq_atd",
282
  """An atd 4x upscaling model, similiar to the 4xNomos2_hq_dat2 or 4xNomos2_hq_mosr models, trained and for usage on non-degraded input to give good quality output.
283
+ """],
284
+
285
+ # MoSR
286
+ "4xNomos2_hq_mosr.pth" : ["https://github.com/Phhofm/models/releases/download/4xNomos2_hq_mosr/4xNomos2_hq_mosr.pth",
287
+ "https://github.com/Phhofm/models/releases/tag/4xNomos2_hq_mosr",
288
+ """A 4x MoSR upscaling model, meant for non-degraded input, since this model was trained on non-degraded input to give good quality output.
289
  """],
290
  }
291
 
 
318
  model_type = "DRCT"
319
  elif "atd" in model_name.lower():
320
  model_type = "ATD"
321
+ elif "mosr" in model_name.lower():
322
+ model_type = "MoSR"
323
  return f"{model_type}, {model_name}"
324
 
325
  typed_upscale_models = {get_model_type(key): value[0] for key, value in upscale_models.items()}
 
457
  upsampler=upsampler,
458
  use_checkpoint=False,
459
  )
460
+ elif upscale_type == "MoSR":
461
+ from basicsr.archs.mosr_arch import mosr
462
+ model = mosr(in_ch = 3,
463
+ out_ch = 3,
464
+ upscale = self.netscale,
465
+ n_block = 24,
466
+ dim = 64,
467
+ upsampler = "ps", # "ps" "ds"
468
+ drop_path = 0.0,
469
+ kernel_size = 7,
470
+ expansion_ratio = 1.5,
471
+ conv_ratio = 1.0
472
+ )
473
 
474
  self.upsampler = None
475
  if model:
 
741
  for key, _ in typed_upscale_models.items():
742
  upscale_type, upscale_model = key.split(", ", 1)
743
  if tmptype and tmptype != upscale_type:#RRDB ESRGAN
744
+ speed = "Fast" if tmptype == "SRVGG" else ("Slow" if any(value == tmptype for value in ("DAT", "HAT", "DRCT", "ATD")) else "Normal")
745
  upscale_model_header = f"| Upscale Model | Info, Type: {tmptype}, Model execution speed: {speed} | Download URL |\n|------------|------|--------------|"
746
  upscale_model_tables.append(upscale_model_header + "\n" + "\n".join(rows))
747
  rows.clear()
 
749
  value = upscale_models[upscale_model]
750
  row = f"| [{upscale_model}]({value[1]}) | " + value[2].replace("\n", "<br>") + " | [download]({value[0]}) |"
751
  rows.append(row)
752
+ speed = "Fast" if tmptype == "SRVGG" else ("Slow" if any(value == tmptype for value in ("DAT", "HAT", "DRCT", "ATD")) else "Normal")
753
  upscale_model_header = f"| Upscale Model Name | Info, Type: {tmptype}, Model execution speed: {speed} | Download URL |\n|------------|------|--------------|"
754
  upscale_model_tables.append(upscale_model_header + "\n" + "\n".join(rows))
755