Conversation
There was a problem hiding this comment.
Pull request overview
Updates example inference scripts to avoid NumPy conversion failures when running models with torch.bfloat16 (and/or CUDA tensors), ensuring outputs can be converted to NumPy for downstream formatting/printing.
Changes:
- Cast landmark coordinate outputs to CPU
float32before calling.numpy(). - Cast classification probability tensors to
float32before calling.numpy()when buildingprobs_dict.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cinema/examples/inference/landmark_coordinate.py |
Move landmark coordinate tensor to CPU and cast to float32 before NumPy conversion. |
cinema/examples/inference/classification_vendor.py |
Cast probability tensor to float32 before NumPy conversion for dict construction. |
cinema/examples/inference/classification_sex.py |
Cast probability tensor to float32 before NumPy conversion for dict construction. |
cinema/examples/inference/classification_cvd.py |
Cast probability tensor to float32 before NumPy conversion for dict construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Convert BFloat16 tensors to float32 before calling .numpy() - Fixes TypeError: Got unsupported ScalarType BFloat16 - Affects classification_cvd.py, classification_sex.py, and classification_vendor.py - Numpy doesn't support BFloat16 directly, requires conversion to float32 first
- Add .cpu().float() before .numpy() to handle BFloat16 tensors - Fixes TypeError: Got unsupported ScalarType BFloat16 in landmark detection
90c7f0b to
2b5b33b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Fix np.argmax(logits) in classification scripts - Fix heatmap_soft_argmax output in landmark_heatmap.py - Ensure all tensor to numpy conversions use .cpu().float().numpy()
No description provided.