Open Aatroy opened 11 months ago
Perhaps it is the inconsistency of the environment that causes the error. Could you please provide a Dockerfile ?
Hi, I had the same problem. It is related to the (not) automatic conversion that occurs when you cast the bfloat16
torch tensor to the float32
numpy array. You should replace this line:
iou_predictions_np = iou_predictions[0].detach().cpu().numpy()
with:
iou_predictions_np = iou_predictions[0].detach().cpu().float().numpy()
so that you force torch to explitly convert the bfloat16
tensor to a float32
one.
Be aware not to use .half()
instead of .float()
since you might risk under/overflow (the representation limits of bfloat16 are the same of the float32, so much more range than fp16 but less precision).
EDIT: Refer to this pull request I just made
I just merged @mawanda-jun's pull request. Please try again and let me know if it doesn't work :) Thank you for your interest in the project!
I use vit_h and code below: sam_fast is segment-anything-fast:main-branch