Yolov5: UnboundLocalError: local variable 'half' referenced before assignment

Created on 15 Jun 2020  路  7Comments  路  Source: ultralytics/yolov5

I just come across this issue recently. It just appeared to be happening after the changes in the test.pt. It was working well before the last changes.

Traceback (most recent call last):
File "/home/Yolov5_github/yolov5-master/train.py", line 400, in
train(hyp)
File "/home/Yolov5_github/yolov5-master/train.py", line 306, in train
fast=ni < n_burn)
File "/home/Yolov5_github/yolov5-master/test.py", line 89, in test
img = img.half() if half else img.float() # uint8 to fp16/32
UnboundLocalError: local variable 'half' referenced before assignment

I was just running the below code to train:

python3 train.py \
--img-size 1280\
--batch 4 \
--epochs 2000 \
--data ./data/custom/test_81.yaml \
--cfg ./models/custom/yolov5l.yaml \
--weights '' \
--name test_81_yolov5l \
--cache \
--rect

```

  • OS: Ubuntu 20.04 LTS
  • GPU [RTX 2070 ]
bug

Most helpful comment

@yasindagasan ok, yes I am able to reproduce. I will push a fix for this shortly.

All 7 comments

Hello @yasindagasan, thank you for your interest in our work! Please visit our Custom Training Tutorial to get started, and see our Jupyter Notebook Open In Colab, Docker Image, and Google Cloud Quickstart Guide for example environments.

If this is a bug report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom model or data training question, please note that Ultralytics does not provide free personal support. As a leader in vision ML and AI, we do offer professional consulting, from simple expert advice up to delivery of fully customized, end-to-end production solutions for our clients, such as:

  • Cloud-based AI systems operating on hundreds of HD video streams in realtime.
  • Edge AI integrated into custom iOS and Android apps for realtime 30 FPS video inference.
  • Custom data training, hyperparameter evolution, and model exportation to any destination.

For more information please visit https://www.ultralytics.com.

@yasindagasan thanks for the bug report. Yes, we recently pushed a commit to default testing to FP16. I will try to reproduce your error in colab.

@yasindagasan ok, yes I am able to reproduce. I will push a fix for this shortly.

@yasindagasan you're welcome, you should be all set now!

I suppose I should do a better job of running tests before commits...

@yasindagasan ok, yes I am able to reproduce. I will push a fix for this shortly.

thanks very much!

@yasindagasan you're welcome, you should be all set now!

I suppose I should do a better job of running tests before commits...

It's all good mate, cheers!

do you solve this,I have same problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

we1pingyu picture we1pingyu  路  3Comments

KangHoyong picture KangHoyong  路  3Comments

Single430 picture Single430  路  4Comments

krishnam3065 picture krishnam3065  路  4Comments

jaqub-manuel picture jaqub-manuel  路  4Comments