Browse Source

Fix pylint: do not use bare 'except' (#5025)

* Fix E722, do not use bare 'except'

* Remove used codes

* Add FileNotFoundError in LoadImagesAndLabels

* Remove AssertionError

* Ignore LoadImagesAndLabels

* Ignore downloads.py

* Ignore torch_utils.py

* Ignore train.py

* Ignore datasets.py

* Enable utils/download.py

* Fixing exception in thop

* Remove unused code

* Fixing exception in LoadImagesAndLabels

* Fixing exception in exif_size

* Fixing exception in parse_model

* Ignore exceptions in requests

* Revert the exception as suggested

* Revert the exception as suggested
modifyDataloader
Zhiqiang Wang GitHub 3 years ago
parent
commit
1922ddeac0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions
  1. +1
    -1
      models/tf.py
  2. +1
    -1
      models/yolo.py
  3. +0
    -1
      train.py
  4. +5
    -4
      utils/general.py

+ 1
- 1
models/tf.py View File

@@ -268,7 +268,7 @@ def parse_model(d, ch, model, imgsz): # model_dict, input_channels(3)
for j, a in enumerate(args):
try:
args[j] = eval(a) if isinstance(a, str) else a # eval strings
except:
except NameError:
pass

n = max(round(n * gd), 1) if n > 1 else n # depth gain

+ 1
- 1
models/yolo.py View File

@@ -233,7 +233,7 @@ def parse_model(d, ch): # model_dict, input_channels(3)
for j, a in enumerate(args):
try:
args[j] = eval(a) if isinstance(a, str) else a # eval strings
except:
except NameError:
pass

n = n_ = max(round(n * gd), 1) if n > 1 else n # depth gain

+ 0
- 1
train.py View File

@@ -499,7 +499,6 @@ def main(opt, callbacks=Callbacks()):
# DDP mode
device = select_device(opt.device, batch_size=opt.batch_size)
if LOCAL_RANK != -1:
from datetime import timedelta
assert torch.cuda.device_count() > LOCAL_RANK, 'insufficient CUDA devices for DDP command'
assert opt.batch_size % WORLD_SIZE == 0, '--batch-size must be multiple of CUDA device count'
assert not opt.image_weights, '--image-weights argument is not compatible with DDP training'

+ 5
- 4
utils/general.py View File

@@ -152,7 +152,7 @@ def is_colab():
try:
import google.colab
return True
except Exception as e:
except ImportError:
return False


@@ -160,6 +160,7 @@ def is_pip():
# Is file in a pip package?
return 'site-packages' in Path(__file__).resolve().parts


def is_ascii(s=''):
# Is string composed of all ASCII (no UTF) characters? (note str().isascii() introduced in python 3.7)
s = str(s) # convert list, tuple, None, etc. to str
@@ -741,11 +742,11 @@ def print_mutation(results, hyp, save_dir, bucket):
data = pd.read_csv(evolve_csv)
data = data.rename(columns=lambda x: x.strip()) # strip keys
i = np.argmax(fitness(data.values[:, :7])) #
f.write(f'# YOLOv5 Hyperparameter Evolution Results\n' +
f.write('# YOLOv5 Hyperparameter Evolution Results\n' +
f'# Best generation: {i}\n' +
f'# Last generation: {len(data)}\n' +
f'# ' + ', '.join(f'{x.strip():>20s}' for x in keys[:7]) + '\n' +
f'# ' + ', '.join(f'{x:>20.5g}' for x in data.values[i, :7]) + '\n\n')
'# ' + ', '.join(f'{x.strip():>20s}' for x in keys[:7]) + '\n' +
'# ' + ', '.join(f'{x:>20.5g}' for x in data.values[i, :7]) + '\n\n')
yaml.safe_dump(hyp, f, sort_keys=False)

if bucket:

Loading…
Cancel
Save