0% found this document useful (0 votes)
15 views2 pages

Rnntransformer

Uploaded by

Sree M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Rnntransformer

Uploaded by

Sree M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Excellent!

The print output reveals the issue:

w0: 256, type: <class 'int'>

h0: 256, type: <class 'int'>

s: 0.9492818934403391, type: <class 'numpy.float64'>

t: [[126.80995542]

[ 88.32458743]], type: <class 'numpy.ndarray'>, shape (if array): (2, 1)

The variable t is a NumPy array with a shape of (2, 1). This means it's a 2D array (two rows, one
column), where the translation values are nested within their own lists. When the code tries to
access t[0] and t[1], it's getting these single-element lists (or 1D arrays of size 1), not the scalar float
values that np.array expects for trans_params.

The Solution:

You need to extract the scalar values from the t array before using them to create trans_params. You
can do this by accessing the element at index [0, 0] and [1, 0] of the t array.

Modify the align_img function in preprocess.py:

1. Open the file: C:\Users\sathe\Stable Diffusion\stable-diffusion-webui/extensions/SadTalker\


src\face3d\util\preprocess.py

2. Locate the line: Around line 104 (where the error occurs):

Python

trans_params = np.array([w0, h0, s, t[0], t[1]])

3. Change the line to extract the scalar values from t:

Python

trans_params = np.array([w0, h0, s, t[0][0], t[1][0]])

By using t[0][0] and t[1][0], you are accessing the element at the first row and first column of the t
array, which should be the scalar translation values.

4. Remove the print() statements you added for debugging (optional, but good practice for
cleaner code).

5. Save the preprocess.py file.

6. Restart Stable Diffusion WebUI.

7. Test SadTalker again.

Explanation of the Change:

The original code was trying to put a list (the result of t[0] and t[1]) into a NumPy array that expects
individual numbers. By using t[0][0], we are accessing the actual numerical value stored at the first
position of the first "row" of t. Similarly, t[1][0] accesses the value in the second "row". This ensures
that np.array receives individual scalar values to construct the trans_params array with the expected
shape.
This should resolve the ValueError you were encountering. Let me know if you still face any issues
after making this change!

You might also like