anticdimi / CloSe

This repository contains official implementation of 3DV'24 paper: CloSe: A 3D Clothing Segmentation Dataset and Model
MIT License
60 stars 2 forks source link

RenderPeople Labels seems not correct. #6

Open zfonemore opened 3 months ago

zfonemore commented 3 months ago

Hi, I am using the labels of RenderPeople dataset recently, and find that the length of labels is not the same as vertices. For example, the rp_alison_posed_027_30k scan has 16890 vertices, but only 14999 labels.

Also, the labels has the same order problem like the labels of THuman2 dataset. image

Can you fix these problem?

Thanks

garvita-tiwari commented 3 months ago

My guess is that the reordering is probably due to the mesh loading function. Could you share the script you are using? I will verify it with the Renderpeople scans I have.

Alternatively, you can try loading the mesh the way we prepare the data. We have a long pipeline, and it requires loading the mesh twice.

  1. We load original renderpeople scans using the script used here: https://github.com/mattloper/opendr/blob/bc16a6a51771d6e062d088ba5cede66649b7c7ec/opendr/serialization.py#L50

  2. We save the above mesh and then reload in later stage using using pytorch3d: https://github.com/anticdimi/CloSe/blob/01ee5bdc30d8bc10eacd390ecea06d5fb5243e2d/prep_scan.py#L47

zfonemore commented 2 months ago

Thanks for your reply, I just use trimesh to load the renderpeople scans, and the code is as follow:


import trimesh
import numpy as np
from PIL import Image
import open3d as o3d

def read_obj(obj_file, img_file):
    mesh = trimesh.load(obj_file, order=False, process=True)

    texture_image = Image.open(img_file)
    texture_image = texture_image.convert('RGB')
    texture_data = np.array(texture_image)
    uv_coords = mesh.visual.uv

    pixel_coords = uv_coords.copy()
    pixel_coords[:, 0] = uv_coords[:, 0] * (texture_image.width - 1)
    pixel_coords[:, 1] = (1 - uv_coords[:, 1]) * (texture_image.height - 1)
    pixel_coords = pixel_coords.astype(int)

    pixel_coords = np.clip(pixel_coords, 0, [texture_image.width - 1, texture_image.height - 1])

    vertex_colors = texture_data[pixel_coords[:, 1], pixel_coords[:, 0]] / 255.0

    vertices = mesh.vertices
    normals = mesh.vertex_normals
    faces = mesh.faces

    return vertices, vertex_colors, normals, faces

obj_file = '/mnt1/dataset/renderpeople/zips/rp_alison_posed_027_OBJ/rp_alison_posed_027_100k.obj'
img_file = '/mnt1/dataset/renderpeople/zips/rp_alison_posed_027_OBJ/tex/rp_alison_posed_027_dif_8k.jpg'
points, colors, normals, faces = read_obj(obj_file, img_file)
garvita-tiwari commented 1 week ago

YOu are changing the vertex order in mesh. You should change mesh = trimesh.load(obj_file, order=False, process=True) to

mesh = trimesh.load(obj_file, maintain_order=True, process=False)