write_mesh.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. __author__ = "Christian Heider Nielsen"
  4. __doc__ = r"""
  5. Created on 28-03-2021
  6. """
  7. import torch
  8. from draugr import PROJECT_APP_PATH
  9. from draugr.torch_utilities import (
  10. TensorBoardPytorchWriter,
  11. )
  12. if __name__ == "__main__":
  13. def main():
  14. """
  15. TODO:!!!!"""
  16. with TensorBoardPytorchWriter(
  17. PROJECT_APP_PATH.user_log / "Tests" / "Writers"
  18. ) as writer:
  19. vertices_tensor = torch.as_tensor(
  20. [
  21. [1, 1, 1],
  22. [-1, -1, 1],
  23. [1, -1, -1],
  24. [-1, 1, -1],
  25. ],
  26. dtype=torch.float,
  27. ).unsqueeze(0)
  28. colors_tensor = torch.as_tensor(
  29. [
  30. [255, 0, 0],
  31. [0, 255, 0],
  32. [0, 0, 255],
  33. [255, 0, 255],
  34. ],
  35. dtype=torch.int,
  36. ).unsqueeze(0)
  37. faces_tensor = torch.as_tensor(
  38. [
  39. [0, 2, 3],
  40. [0, 3, 1],
  41. [0, 1, 2],
  42. [1, 3, 2],
  43. ],
  44. dtype=torch.int,
  45. ).unsqueeze(0)
  46. writer.mesh(
  47. "my_mesh", vertices_tensor, colors=colors_tensor, faces=faces_tensor
  48. )
  49. main()