Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for usage - Cuda error #46

Open
oliversunde opened this issue Apr 19, 2022 · 9 comments
Open

Documentation for usage - Cuda error #46

oliversunde opened this issue Apr 19, 2022 · 9 comments

Comments

@oliversunde
Copy link

Hey, I have for some hours now tried to use MagFace with no luck.
I want to take a lot of images, check the image quality regarding biometric features and print that data. However, I get the RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

Is there a tutorial/documentation for how to use MagFace with all prerequisites?

Thank you

@IrvingMeng
Copy link
Owner

Hi,

You can add the param '--cpu-mode' to run the code on a CPU-only machine. For example, use python3 gen_feat.py --cpu-mode ... instead of python3 gen_feat.py ... in this example.

@oliversunde
Copy link
Author

Thank you Irving!

How do you calculate the feat.list?

@IrvingMeng
Copy link
Owner

feat.list is generated by the command
python3 gen_feat.py --inf_list toy_imgs/img.list --feat_list toy_imgs/feat.list --resume magface_epoch_00025.pth --cpu-mode

@oliversunde
Copy link
Author

Thank you so so so much Irving! I have managed to calculate the feat.list, The script generates the mean quality score and I have a folder with 500 images where I want to get each single image's quality score. Is it possible to edit the

python3 gen_feat.py --inf_list toy_imgs/img.list --feat_list toy_imgs/feat.list --resume magface_epoch_00025.pth --cpu-mode
to make it print that score on the run or is it another way around?

@IrvingMeng
Copy link
Owner

The script does not generate the mean quality score. It generates the feature embedding for each image. Here is an example : https://github.com/IrvingMeng/MagFace/blob/main/inference/toy_imgs/feat.list#L1-L10

@oliversunde
Copy link
Author

Extract Features: [0/1] Time 8.675 ( 8.675) Data 0.133 ( 0.133)

What does "Data" in this section mean?

@IrvingMeng
Copy link
Owner

The duration for loading data[1].

[1] https://github.com/IrvingMeng/MagFace/blob/main/inference/gen_feat.py#L134-L135

@oliversunde
Copy link
Author

Thank you so much Irving!

I am printing "mag" in ln4 which produces the 10 feature magnitudes - how do I collect an image's quality measurement? I get the pink visual recognition after ln9, but I am not really understanding it unfortunately
Further I am getting this error in the "ln6" part of the script:


TypeError Traceback (most recent call last)
in
6 imgname = '/'.join(imgnames[ele].split('/')[-2:])
7 img = cv2.imread(imgname)
----> 8 canvas[int(i / NW) * H: (int(i / NW) + 1) * H, (i % NW) * W: ((i % NW) + 1) * W, :] = img

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

@IrvingMeng
Copy link
Owner

Magnitudes are quality measurements. That is well described in our paper.

For the error, the TypeError states that int() gets NoneType inputs. This shouldn't be hard to debug. You just need to check whether the inputs are valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants