When I use your model to predict my image, I save the mat file of the image, then I load the saved mat file and execute the render_texture function of utils/render.py when I get The following error:
IndexError Traceback (most recent call last)
<ipython-input-12-67a5eb198033> in <module>
----> 1 imgs = render_texture(vertices,colors,triangles, h,w)
~/sda1/人脸识别/PRNet/utils/render.py in render_texture(vertices, colors, triangles, h, w, c)
97 depth_buffer = np.zeros([h, w]) - 999999.
98 # triangle depth: approximate the depth to the average value of z in each vertex(v0, v1, v2), since the vertices are closed to each other
---> 99 tri_depth = (vertices[2, triangles[0,:]] + vertices[2,triangles[1,:]] + vertices[2, triangles[2,:]])/3.
100 tri_tex = (colors[:, triangles[0,:]] + colors[:,triangles[1,:]] + colors[:, triangles[2,:]])/3.
101
IndexError: index 247 is out of bounds for axis 1 with size 3
My code is as follows:
from utils.render import *
from utils.render_app import *
import numpy as np
import scipy.io as scio
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
mat_file = scio.loadmat("images/img_pre/詹姆斯_mesh.mat")
vertices = mat_file['vertices']
colors = mat_file['colors']
triangles = mat_file['triangles']
img = cv2.imread("images/img/詹姆斯.jpg")
h = img.shape[0]
w = img.shape[1]
imgs = render_texture(vertices,colors,triangles, h,w)
I don't understand why it went wrong, because triangles is from the files you provided, how can I solve this error? Can you give me some knowledge? Thank you.
Hello, I had the similar issue. I solved it by providing transpose of the given arrays as it shown in get_depth_image() function in demo.py .:
imgs = render_texture(vertices.T,colors.T,triangles.T, h,w).
When I use your model to predict my image, I save the
mat
file of the image, then I load the savedmat
file and execute therender_texture
function ofutils/render.py
when I get The following error:My code is as follows:
I don't understand why it went wrong, because
triangles
is from the files you provided, how can I solve this error? Can you give me some knowledge? Thank you.