catch more specific errors
This commit is contained in:
@@ -94,7 +94,7 @@ def main():
|
||||
_, _, output = face_enhancer.enhance(img, has_aligned=False, only_center_face=False, paste_back=True)
|
||||
else:
|
||||
output, _ = upsampler.enhance(img, outscale=args.outscale)
|
||||
except Exception as error:
|
||||
except RuntimeError as error:
|
||||
print('Error', error)
|
||||
print('If you encounter CUDA out of memory, try to set --tile with a smaller number.')
|
||||
else:
|
||||
|
||||
@@ -92,7 +92,7 @@ class RealESRGANDataset(data.Dataset):
|
||||
while retry > 0:
|
||||
try:
|
||||
img_bytes = self.file_client.get(gt_path, 'gt')
|
||||
except Exception as e:
|
||||
except (IOError, OSError) as e:
|
||||
logger = get_root_logger()
|
||||
logger.warn(f'File client error: {e}, remaining retry times: {retry - 1}')
|
||||
# change another file to read
|
||||
|
||||
@@ -128,7 +128,7 @@ class RealESRGANer():
|
||||
try:
|
||||
with torch.no_grad():
|
||||
output_tile = self.model(input_tile)
|
||||
except Exception as error:
|
||||
except RuntimeError as error:
|
||||
print('Error', error)
|
||||
print(f'\tTile {tile_idx}/{tiles_x * tiles_y}')
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ def main(args):
|
||||
# read the image once for check, as some images may have errors
|
||||
try:
|
||||
img = cv2.imread(img_path)
|
||||
except Exception as error:
|
||||
except (IOError, OSError) as error:
|
||||
print(f'Read {img_path} error: {error}')
|
||||
status = False
|
||||
if img is None:
|
||||
|
||||
Reference in New Issue
Block a user