ahmedbesbes / cartoonify

Deploy and scale serverless machine learning app - in 4 steps.
https://cartoonify.netlify.app/
MIT License
407 stars 81 forks source link

This PR solves allow all tensors will be in the same device #8

Open hdnh2006 opened 1 year ago

hdnh2006 commented 1 year ago

If in the function transform (https://github.com/hdnh2006/cartoonify/blob/a37167c5cda7a56362395271d30aecd5098bbbcd/cartoongan/test_from_code.py#L14) we set gpu = 0. The code fails because torch.FloatTensor([n]) is not set in the same device as var, so the operation

var = var.unsqueeze(2).unsqueeze(3).expand_as(x) * (
            (n - 1) / torch.FloatTensor([n]).to(var.device)
        )

will fail...