paul-pias / Object-Detection-and-Distance-Measurement

Using yolov3 & yolov4 weights objects are being detected from live video frame along with the measurement of the object from the camera without the support of any extra hardware device.
348 stars 118 forks source link

RuntimeError: "clamp_cpu" not implemented for 'Half' #8

Closed mayankcstech closed 4 years ago

mayankcstech commented 4 years ago

Hi

I have just started implementing it. Trying to run the code "object_detection.py" for a video. I am able to read the video, resize it, as is inside the code. Although I am getting the following error:

Traceback (most recent call last): File "object_detection.py", line 141, in <module> ObjectDetection(id).main() File "object_detection.py", line 110, in main output[:,1:5] = torch.clamp(output[:,1:5], 0.0, float(self.inp_dim))/self.inp_dim RuntimeError: "clamp_cpu" not implemented for 'Half'

When I commented out the line

output = output.type(torch.half)

it works and does detection. But I am not sure if that's the right way to resolve the error. Please guide as what would be the issue. Thanks!

paul-pias commented 4 years ago

Which Pytorch Version you are using?

mayankcstech commented 4 years ago

Hi,

I am using pytorch 1.4.0 on python 3.7. Thanks!

paul-pias commented 4 years ago

There is no error in my side. However, the type of the data was converted to float16 from float32 to speed up the execution time. If you are still facing the issue change torch.half to torch.float in line 104. Kindly let me know if it solves your issue.