deepinsight / deepinsight/insightface

Cast error with PyTorch 1.12 in label

Open
#2,241 2 comments 0 reactions 1 assignee Claimed by @anxiangsir View on GitHub
arcface_torch
Dominant language
Python
Stars
29.7k
Forks
6.1k
PR merge metrics
No merged PRs in 30d

Description

Hello,

Thanks for making your code available.

Since the update to PyTorch 1.12, I have an error due to a float label value not castable to a long one:

```
File "[...]/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 49, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "[...]/insightface/recognition/arcface_torch/dataset.py", line 166, in __getitem__
label = torch.tensor(label, dtype=torch.long)
TypeError: 'float' object cannot be interpreted as an integer
```

https://github.com/deepinsight/insightface/blob/f488f4de5622c4001b52f98845f6ba422c34ec77/recognition/arcface_torch/dataset.py#L165

I tried to regenerate the `.rec` file with labels of type long (by removing `.000000` in the `train.lst`) but that does not work.

However, updating the line with `label = torch.tensor(int(label), dtype=torch.long)` solves the issue.

Does anyone get the same problem?

Thanks.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.