Inference algorithm for finite-dimensional spin glasses: Belief propagation on the dual lattice