doevent commited on
Commit
b0f7a83
1 Parent(s): d0b54f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -30,6 +30,7 @@ def inference(image, size):
30
  try:
31
  result = model2.predict(image.convert('RGB'))
32
  except torch.cuda.OutOfMemoryError as e:
 
33
  model2 = RealESRGAN(device, scale=2)
34
  model2.load_weights('weights/RealESRGAN_x2.pth', download=False)
35
  result = model2.predict(image.convert('RGB'))
@@ -37,16 +38,18 @@ def inference(image, size):
37
  try:
38
  result = model4.predict(image.convert('RGB'))
39
  except torch.cuda.OutOfMemoryError as e:
 
40
  model4 = RealESRGAN(device, scale=4)
41
  model4.load_weights('weights/RealESRGAN_x4.pth', download=False)
42
- result = model4.predict(image.convert('RGB'))
43
  else:
44
  try:
45
  result = model8.predict(image.convert('RGB'))
46
  except torch.cuda.OutOfMemoryError as e:
 
47
  model8 = RealESRGAN(device, scale=8)
48
  model8.load_weights('weights/RealESRGAN_x8.pth', download=False)
49
- result = model8.predict(image.convert('RGB'))
50
 
51
  print(f"Image size ({device}): {size} ... OK")
52
  return result
 
30
  try:
31
  result = model2.predict(image.convert('RGB'))
32
  except torch.cuda.OutOfMemoryError as e:
33
+ print(e)
34
  model2 = RealESRGAN(device, scale=2)
35
  model2.load_weights('weights/RealESRGAN_x2.pth', download=False)
36
  result = model2.predict(image.convert('RGB'))
 
38
  try:
39
  result = model4.predict(image.convert('RGB'))
40
  except torch.cuda.OutOfMemoryError as e:
41
+ print(e)
42
  model4 = RealESRGAN(device, scale=4)
43
  model4.load_weights('weights/RealESRGAN_x4.pth', download=False)
44
+ result = model2.predict(image.convert('RGB'))
45
  else:
46
  try:
47
  result = model8.predict(image.convert('RGB'))
48
  except torch.cuda.OutOfMemoryError as e:
49
+ print(e)
50
  model8 = RealESRGAN(device, scale=8)
51
  model8.load_weights('weights/RealESRGAN_x8.pth', download=False)
52
+ result = model2.predict(image.convert('RGB'))
53
 
54
  print(f"Image size ({device}): {size} ... OK")
55
  return result