Hi there,
It seems perhaps that you're rounding the contour data too early in your code. The contour_data is changed to type 'int' here, before being converted to the pixel coordinates. I think you can just remove .astype(int) as it's converted to 'int32' further on.
This change can make a difference to the resulting mask, please see attached example where I forked the code and applied the change to the fork:
https://colab.research.google.com/drive/1anBcwIGgrGcPDbsyIDrNqgb0H9UZxJhC?usp=sharing