Open vshesh opened 2 years ago
I see sorry I'm supposed to use val.py
.
Actually now I am confused because there is detect.py at the bottom of the docs with --hide-txt --hide-conf
. This is useful for me because I have a --source /some/folder
instead of a dataset with validation that needs to happen.
@vshesh I get the same error. Were you able to save the detected bounding boxes in text files?
I was able to run detection on the validation set using val.py
. So I have those in txt files.
Beyond that no, I wasn't able to get detect.py
working with --save-txt
and --save-conf
I am working with just one class, so the below workaround worked for me for saving labels with detect.py https://github.com/hukaixuan19970627/yolov5_obb/blob/6f9ea7d78851d2638cc0d53112cf0b825778e1b3/detect.py#L159-L162
# poly = poly.tolist()
# line = (cls, *poly, conf) if save_conf else (cls, *poly) # label format
poly_value = [x.item() for x in poly]
line = (cls, *poly, conf) if save_conf else (*poly,) # label format
with open(txt_path + '.txt', 'a') as f:
f.write(('%g ' * len(line)).rstrip() % line + ' screws 0'+ '\n')
Where screws is the object class and difficulty is always 0
maybe you can try "poly = torch.tensor(poly).view(1, 8).view(-1).tolist()" instead "poly = poly.tolist()"
In Colab
Result
Removing
--save-txt
makes the error go away and detection is fine.