Comments (1)
I found the reason is that num_frames//4, num_frames//2. And I update two methods of edit_sequences.py then the problem disappear.
def alter_sequence_shape(source_path, out_path, flame_model_fname, pc_idx=0, pc_range=(0,3)):
'''
Load existing animation sequence in "zero pose" and change the identity dependent shape over time.
:param source_path: path of the animation sequence (files must be provided in OBJ file format)
:param out_path: output path of the altered sequence
:param flame_model_fname: path of the FLAME model
:param pc_idx Identity shape parameter to be varied in [0,300) as FLAME provides 300 shape paramters
:param pc_range Tuple (start/end, max/min) defining the range of the shape variation.
i.e. (0,3) varies the shape from 0 to 3 stdev and back to 0
'''
if pc_idx < 0 or pc_idx >= 300:
print('shape parameter index out of range [0,300)')
return
if not os.path.exists(out_path):
os.makedirs(out_path)
# Load sequence files
sequence_fnames = sorted(glob.glob(os.path.join(source_path, '*.obj')))
num_frames = len(sequence_fnames)
if num_frames == 0:
print('No sequence meshes found')
return
# Load FLAME head model
model = load_model(flame_model_fname)
model_parms = np.zeros((num_frames, 300))
# Generate interpolated shape parameters for each frame
half_n = int(num_frames / 2)
x1, y1 = [0, half_n], pc_range
x2, y2 = [half_n, num_frames], pc_range[::-1]
xsteps1 = np.arange(0, half_n)
xsteps2 = np.arange(half_n, num_frames)
model_parms[:, pc_idx] = np.hstack((np.interp(xsteps1, x1, y1), np.interp(xsteps2, x2, y2)))
predicted_vertices = np.zeros((num_frames, model.v_template.shape[0], model.v_template.shape[1]))
for frame_idx in range(num_frames):
model.v_template[:] = Mesh(filename=sequence_fnames[frame_idx]).v
model.betas[:300] = model_parms[frame_idx]
predicted_vertices[frame_idx] = model.r
output_sequence_meshes(predicted_vertices, Mesh(model.v_template, model.f), out_path)
def alter_sequence_head_pose(source_path, out_path, flame_model_fname, pose_idx=3, rot_angle=np.pi/6):
'''
Load existing animation sequence in "zero pose" and change the head pose (i.e. rotation around the neck) over time.
:param source_path: path of the animation sequence (files must be provided in OBJ file format)
:param out_path: output path of the altered sequence
:param flame_model_fname: path of the FLAME model
:param pose_idx: head pose parameter to be varied in [3,6)
:param rot_angle: maximum rotation angle in [0,2pi)
'''
if pose_idx < 3 or pose_idx >= 6:
print('pose parameter index out of range [3,6)')
return
if not os.path.exists(out_path):
os.makedirs(out_path)
# Load sequence files
sequence_fnames = sorted(glob.glob(os.path.join(source_path, '*.obj')))
num_frames = len(sequence_fnames)
if num_frames == 0:
print('No sequence meshes found')
return
# Load FLAME head model
model = load_model(flame_model_fname)
model_parms = np.zeros((num_frames, model.pose.shape[0]))
# Generate interpolated pose parameters for each frame
num_4 = int(num_frames//4)
num_2 = int(num_frames//2)
x1, y1 = [0, num_4], [0, rot_angle]
x2, y2 = [num_4, num_2], [rot_angle, 0]
x3, y3 = [num_2, 3*num_4], [0, -rot_angle]
x4, y4 = [3*num_4, num_frames], [-rot_angle, 0]
xsteps1 = np.arange(0, num_4)
xsteps2 = np.arange(num_4, num_2)
xsteps3 = np.arange(num_2, 3*num_4)
xsteps4 = np.arange(3*num_4, num_frames)
model_parms[:, pose_idx] = np.hstack((np.interp(xsteps1, x1, y1),
np.interp(xsteps2, x2, y2),
np.interp(xsteps3, x3, y3),
np.interp(xsteps4, x4, y4)))
predicted_vertices = np.zeros((num_frames, model.v_template.shape[0], model.v_template.shape[1]))
for frame_idx in range(num_frames):
model.v_template[:] = Mesh(filename=sequence_fnames[frame_idx]).v
model.pose[:] = model_parms[frame_idx]
predicted_vertices[frame_idx] = model.r
output_sequence_meshes(predicted_vertices, Mesh(model.v_template, model.f), out_path)
from voca.
Related Issues (20)
- is the eye blink useful for FLame 2020 model ? HOT 3
- "video.mp4" only has speech but no images ? HOT 4
- Windows support and installing MPI-IS / mesh HOT 1
- Should --uv_template_fname be the same as --template_fname in run_voca.py?
- can you give pretrained_models?
- Initialization Of Decoder Layer
- Problem of training voca
- How to control expression in the edit_sequence.py? HOT 2
- Can I train this on custom dataset?
- Unknown mesh file format. HOT 1
- Training with new Tensorflow Version
- Unsolved reference tfbody
- Missing data on subj_seq_to_idx.pkl file HOT 1
- If I want to control the expression of the eyes, how should I set the parameters?
- I haven't found the 'output_graph.pb' file, where can I get it?
- dataset/voca_face_former/templates.pkl not found HOT 1
- Where to download npy and pkl files HOT 1
- Inference other .ply files
- Hot to get blink_exp_betas for another flame version?
- Is the the vertice's coordinates in registered data the same as it in data_verts.npy in training data? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voca.