Skip to content

Commit addfbd4

Browse files
glenn-jochertdhooghe
authored andcommitted
Remove formats variable to avoid pd conflict (ultralytics#7993)
* Remove `formats` variable to avoid `pd` conflict * Update export.py
1 parent 37fb916 commit addfbd4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

export.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,9 @@ def run(
479479
):
480480
t = time.time()
481481
include = [x.lower() for x in include] # to lowercase
482-
formats = tuple(export_formats()['Argument'][1:]) # --include arguments
483-
flags = [x in include for x in formats]
484-
assert sum(flags) == len(include), f'ERROR: Invalid --include {include}, valid --include arguments are {formats}'
482+
fmts = tuple(export_formats()['Argument'][1:]) # --include arguments
483+
flags = [x in include for x in fmts]
484+
assert sum(flags) == len(include), f'ERROR: Invalid --include {include}, valid --include arguments are {fmts}'
485485
jit, onnx, xml, engine, coreml, saved_model, pb, tflite, edgetpu, tfjs = flags # export booleans
486486
file = Path(url2file(weights) if str(weights).startswith(('http:/', 'https:/')) else weights) # PyTorch weights
487487

@@ -503,7 +503,7 @@ def run(
503503
im = torch.zeros(batch_size, 3, *imgsz).to(device) # image size(1,3,320,192) BCHW iDetection
504504

505505
# Update model
506-
if half and not (coreml or xml):
506+
if half and not coreml and not xml:
507507
im, model = im.half(), model.half() # to FP16
508508
model.train() if train else model.eval() # training mode = no Detect() layer grid construction
509509
for k, m in model.named_modules():
@@ -536,7 +536,7 @@ def run(
536536
if any((saved_model, pb, tflite, edgetpu, tfjs)):
537537
if int8 or edgetpu: # TFLite --int8 bug https://github.com/ultralytics/yolov5/issues/5707
538538
check_requirements(('flatbuffers==1.12',)) # required before `import tensorflow`
539-
assert not (tflite and tfjs), 'TFLite and TF.js models must be exported separately, please pass only one type.'
539+
assert not tflite or not tfjs, 'TFLite and TF.js models must be exported separately, please pass only one type.'
540540
model, f[5] = export_saved_model(model.cpu(),
541541
im,
542542
file,

utils/benchmarks.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ def run(
5656
pt_only=False, # test PyTorch only
5757
):
5858
y, t = [], time.time()
59-
formats = export.export_formats()
6059
device = select_device(device)
61-
for i, (name, f, suffix, gpu) in formats.iterrows(): # index, (name, file, suffix, gpu-capable)
60+
for i, (name, f, suffix, gpu) in export.export_formats().iterrows(): # index, (name, file, suffix, gpu-capable)
6261
try:
6362
assert i != 9, 'Edge TPU not supported'
6463
assert i != 10, 'TF.js not supported'
@@ -104,9 +103,8 @@ def test(
104103
pt_only=False, # test PyTorch only
105104
):
106105
y, t = [], time.time()
107-
formats = export.export_formats()
108106
device = select_device(device)
109-
for i, (name, f, suffix, gpu) in formats.iterrows(): # index, (name, file, suffix, gpu-capable)
107+
for i, (name, f, suffix, gpu) in export.export_formats().iterrows(): # index, (name, file, suffix, gpu-capable)
110108
try:
111109
w = weights if f == '-' else \
112110
export.run(weights=weights, imgsz=[imgsz], include=[f], device=device, half=half)[-1] # weights

0 commit comments

Comments
 (0)