facenet-pytorch icon indicating copy to clipboard operation
facenet-pytorch copied to clipboard

About MTCNN on GPU

Open Jytylyqyrs opened this issue 3 years ago • 2 comments

Thank you for your great work in facenet-pytorch, I'm a novice at these things, it really gives me useful help.However, I met a problem when I was using MTCNN.I want to put MTCNN on cuda to calculate, but I can't transform the input to the type "torch.cuda.FloatTensor", it usually told me ''Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same'', if possible can you give me some advice.

mtcnn = mtcnn.MTCNN(keep_all=True).eval().to('cuda') img = Image.open('………') img = np.array(img) img = torch.from_numpy(img) img = img.to('cuda') faces = mtcnn(img)

Jytylyqyrs avatar Mar 31 '21 19:03 Jytylyqyrs

You really should read the code and the comments and not make wild guess. There is an argument “device” in the initialization method. If you set it to gpu (using torch) as usual then it will run on CUDA.

Sinuhe96 avatar Feb 17 '23 12:02 Sinuhe96

I know that both models have a parameter device when instantiating the models. However, when using .to(device) the models are not moved to the device and the to(...) call has no effect. As this is a vital feature of PyTorch I think this should be implemented.

D0miH avatar Mar 08 '23 13:03 D0miH