Skip to content

Commit

Permalink
fix classification model cuda move (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanBGG committed Sep 2, 2022
1 parent c492c9d commit 61a53df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doctr/models/classification/predictor/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def forward(
raise ValueError("incorrect input shape: all pages are expected to be multi-channel 2D images.")

processed_batches = self.pre_processor(crops)
predicted_batches = [self.model(batch) for batch in processed_batches]
_device = next(self.model.parameters()).device
predicted_batches = [self.model(batch).to(device=_device) for batch in processed_batches]

# Postprocess predictions
predicted_batches = [out_batch.argmax(dim=1).cpu().detach().numpy() for out_batch in predicted_batches]
Expand Down

0 comments on commit 61a53df

Please sign in to comment.