Skip to content

Commit

Permalink
TFLite --int8 'flatbuffers==1.12' fix 2
Browse files Browse the repository at this point in the history
Reorganizes #6216 fix to update before `tensorflow` import so no restart required.
  • Loading branch information
glenn-jocher authored Jan 5, 2022
1 parent 8125ec5 commit 5dc1707
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion export.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ def export_tflite(keras_model, im, file, int8, data, ncalib, prefix=colorstr('Te
converter.optimizations = [tf.lite.Optimize.DEFAULT]
if int8:
from models.tf import representative_dataset_gen
check_requirements(('flatbuffers==1.12',)) # https://github.com/ultralytics/yolov5/issues/5707
dataset = LoadImages(check_dataset(data)['train'], img_size=imgsz, auto=False) # representative data
converter.representative_dataset = lambda: representative_dataset_gen(dataset, ncalib)
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
Expand Down Expand Up @@ -391,6 +390,8 @@ def run(data=ROOT / 'data/coco128.yaml', # 'dataset.yaml path'
# Checks
imgsz *= 2 if len(imgsz) == 1 else 1 # expand
opset = 12 if ('openvino' in include) else opset # OpenVINO requires opset <= 12
if (('tflite' in include) or ('edgetpu' in include)) and int8:
check_requirements(('flatbuffers==1.12',)) # TFLite fix https://github.com/ultralytics/yolov5/issues/5707

# Load PyTorch model
device = select_device(device)
Expand Down

0 comments on commit 5dc1707

Please sign in to comment.