Skip to content

Instantly share code, notes, and snippets.

@NMO13
Last active August 27, 2019 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMO13/453f66ee5c153a67ec98041f31676785 to your computer and use it in GitHub Desktop.
Save NMO13/453f66ee5c153a67ec98041f31676785 to your computer and use it in GitHub Desktop.
from PIL import Image, ImageFont, ImageDraw, ImageEnhance
import torchvision.transforms.functional as F
# image is the tensor defined as torch.zeros((3, 800, 800)).float()
## visualize all centers and boxes for 1 position
pil_image = F.to_pil_image(image)
draw = ImageDraw.Draw(pil_image)
for anchor in anchor_base:
draw.rectangle(((anchor[1], anchor[0]), (anchor[3], anchor[2])))
draw = ImageDraw.Draw(pil_image)
for center in centers:
draw.point((center[1], center[0]), fill="blue")
pil_image.show()
## visualize all boxes
pil_image = F.to_pil_image(image)
draw = ImageDraw.Draw(pil_image)
for anchor in anchors:
draw.rectangle(((anchor[1], anchor[0]), (anchor[3], anchor[2])))
pil_image.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment