fix: replace bare except with except Exception

Bare except clauses catch all exceptions including SystemExit and
KeyboardInterrupt. Replace with except Exception in image validation
functions (tfcv.py, pytorchcv.py) for ConvNets and TransferLearning.
This commit is contained in:
lxcxjxhx 2026-07-29 21:58:39 +08:00
parent 33e781bf7b
commit 2a066be892
4 changed files with 4 additions and 4 deletions

View File

@ -134,7 +134,7 @@ def check_image(fn):
im = Image.open(fn)
im.verify()
return True
except:
except Exception:
return False
def check_image_dir(path):

View File

@ -48,7 +48,7 @@ def check_image(fn):
im = Image.open(fn)
im.verify()
return im.format=='JPEG'
except:
except Exception:
return False
def check_image_dir(path):

View File

@ -134,7 +134,7 @@ def check_image(fn):
im = Image.open(fn)
im.verify()
return True
except:
except Exception:
return False
def check_image_dir(path):

View File

@ -48,7 +48,7 @@ def check_image(fn):
im = Image.open(fn)
im.verify()
return im.format=='JPEG'
except:
except Exception:
return False
def check_image_dir(path):