-
-
Notifications
You must be signed in to change notification settings - Fork 17.2k
Description
Search before asking
- I have searched the YOLOv5 issues and found no similar bug report.
YOLOv5 Component
Detection
Bug
Detection on edgetpu model returns the following error:
File "yolov5/models/common.py", line 449, in forward y[..., :4] *= [w, h, w, h] # xywh normalized to pixels UnboundLocalError: local variable 'y' referenced before assignment
I believe that the error from is caused by self.tflite
not being set in the if/else branches in the forward method when edgetpu is true (common.py line 438). That should be cause by tflite &= not edgetpu # *.tflite
in the model_type
method.
@staticmethod
def model_type(p='path/to/model.pt'):
# Return model type from model path, i.e. path='path/to/model.onnx' -> type=onnx
from export import export_formats
suffixes = list(export_formats().Suffix) + ['.xml'] # export suffixes
check_suffix(p, suffixes) # checks
p = Path(p).name # eliminate trailing separators
pt, jit, onnx, xml, engine, coreml, saved_model, pb, tflite, edgetpu, tfjs, xml2 = (s in p for s in suffixes)
xml |= xml2 # *_openvino_model or *.xml
tflite &= not edgetpu # *.tflite
return pt, jit, onnx, xml, engine, coreml, saved_model, pb, tflite, edgetpu, tfjs
tflite &= not edgetpu
sets tflite
to true only if tflite
is true and edgetpu
is false, it is set to false otherwise.
Environment
- OS: Ubuntu 20.04
- Python 3.8.10
Minimal Reproducible Example
I have exported the YoloV5s model to edgetpu using:
python export.py --weights yolov5s.pt --include edgetpu --img 320 --data data/coco128.yaml
Then run the detection with python detect.py --weights yolov5s-int8_edgetpu.tflite --img 320 --data data/coco128.yaml
Additional
No response
Are you willing to submit a PR?
- Yes I'd like to help by submitting a PR!