facexlib icon indicating copy to clipboard operation
facexlib copied to clipboard

recognition/__init__.py from 'cuda' to device parameter

Open jeffatllatos opened this issue 1 year ago • 1 comments

Can you change this line only so we can use CPU or GPU.

FROM: model = Backbone(num_layers=50, drop_ratio=0.6, mode='ir_se').to('cuda').eval()

TO: model = Backbone(num_layers=50, drop_ratio=0.6, mode='ir_se').to(device).eval()

jeffatllatos avatar Jan 18 '24 18:01 jeffatllatos

Hello reader! Just in case you reached this place trying to fix this locally, change these two lines in init_recognition_model:

- model = Backbone(num_layers=50, drop_ratio=0.6, mode='ir_se').to('cuda').eval()
+ model = Backbone(num_layers=50, drop_ratio=0.6, mode='ir_se').to(device).eval()

And here, unspecified:

- model.load_state_dict(torch.load(model_path), strict=True)
+ model.load_state_dict(torch.load(model_path, map_location=device), strict=True)

slezica avatar Jun 26 '25 00:06 slezica