Parskatt / DKM

[CVPR 2023] DKM: Dense Kernelized Feature Matching for Geometry Estimation
https://parskatt.github.io/DKM/
Other
378 stars 28 forks source link

inference runs on CPU if no GPU available #25

Closed kemaleren closed 1 year ago

kemaleren commented 1 year ago

I wanted to test this model on a device with no GPU. Even though it is much slower and would not be a good idea in production, for testing small images it still runs in a reasonable amount of time.

Parskatt commented 1 year ago

That's cool! I know other people have also expressed interest on running on CPU/other devices so this seems like a good addition. I'll just verify that your changes don't break anything first :)

Parskatt commented 1 year ago

I think it's probably better practice to have device as inputs to functions/properties of nn.Modules rather than defined outside the local scope, but that's a minor issue.

kemaleren commented 1 year ago

I thought so too, but the PyTorch blog has a section on writing device-agnostic code, that that's what they recommended: https://pytorch.org/blog/pytorch-0_4_0-migration-guide/#writing-device-agnostic-code

kemaleren commented 1 year ago

Also I'm sure there's things that still won't work. If they need to be fixed I can do that. I made these changes to get the demo_match.py script working.

Parskatt commented 1 year ago

I'll merge it and fix any issues later :p