io.md 997 Bytes
Newer Older
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
1
2
3
4
5
6
7
8
9
---
hide_title: true
sidebar_label: File IO
---

# File IO
There is a flexible interface for loading and saving point clouds and meshes from different formats.

The main usage is via the `pytorch3d.io.IO` object, and its methods
10
`load_mesh`, `save_mesh`, `load_pointcloud` and `save_pointcloud`.
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
11
12
13
14
15
16

For example, to load a mesh you might do
```
from pytorch3d.io import IO

device=torch.device("cuda:0")
17
mesh = IO().load_mesh("mymesh.obj", device=device)
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
18
19
20
21
22
```

and to save a pointcloud you might do
```
pcl = Pointclouds(...)
23
IO().save_pointcloud(pcl, "output_pointcloud.ply")
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
24
```
Jeremy Reizenstein's avatar
Jeremy Reizenstein committed
25
26
27
28
29
30
31
32
33

For meshes, this supports OBJ, PLY and OFF files.

For pointclouds, this supports PLY files.

In addition, there is experimental support for loading meshes from
[glTF 2 assets](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0)
stored either in a GLB container file or a glTF JSON file with embedded binary data.
This must be enabled explicitly, as described in
34
`pytorch3d/io/experimental_gltf_io.py`.