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