resouces filenames with spaces (#358)

Summary:
I'm constantly encountering 3D models with resources that have spaces in their filenames (especially on Windows) and therefore they can't be loaded in pytorch3d. Let me know what you think.

Thanks

Pull Request resolved: https://github.com/facebookresearch/pytorch3d/pull/358

Reviewed By: bottler

Differential Revision: D23798492

Pulled By: nikhilaravi

fbshipit-source-id: 4d85b7ee05339486d2e5ef53a531f8e6052251c5
This commit is contained in:
andrijazz
2020-09-23 12:10:53 -07:00
committed by Facebook GitHub Bot
parent 93d3d8feda
commit b1eee579fd
2 changed files with 49 additions and 1 deletions

View File

@@ -399,7 +399,9 @@ def _parse_mtl(f, device="cpu") -> Tuple[MaterialProperties, TextureFiles]:
material_properties[material_name] = {}
elif tokens[0] == "map_Kd":
# Diffuse texture map
texture_files[material_name] = tokens[1]
# Account for the case where filenames might have spaces
filename = line.strip()[7:]
texture_files[material_name] = filename
elif tokens[0] == "Kd":
# RGB diffuse reflectivity
kd = np.array(tokens[1:4]).astype(np.float32)