You can convert your list to a numpy array and then reshape it with numpy.reshape
import numpy as np
# Convert to numpy array
w_train = np.array(w_train)
w_test = np.array(w_train)
# Reshape
w_train = np.reshape(w_train, (2404,28,224,224,3))
w_test = np.reshape(w_test, (601,28,224,224,3))
Answer from MD Mushfirat Mohaimin on Stack OverflowYou can convert your list to a numpy array and then reshape it with numpy.reshape
import numpy as np
# Convert to numpy array
w_train = np.array(w_train)
w_test = np.array(w_train)
# Reshape
w_train = np.reshape(w_train, (2404,28,224,224,3))
w_test = np.reshape(w_test, (601,28,224,224,3))
reshape is a methode under numpy's library and as the error printed in your terminal the object list has no methode defined as reshape
import numpy as np
w_train=np.array(x_train)
then you can simply use the reshape function without any error :
w_train=x_train.reshape((2404,28,224,224,3))
you can check the reshape characteristics in this link for more understanding of the methode
C5W2 Emojify Cell #14. Can't compile the student's code. Error: AttributeError("'list' object has no attribute 'reshape'",)
Seeing AttributeError: 'Dataset' object has no attribute 'reshape' when using "dataset.get_nearest_examples"
python - 'list' object has no attribute 'reshape' - Stack Overflow
python - 'list' object has no attribute 'shape' - Stack Overflow
I got this warning:
VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray. A = np.array([[56.0, 0.0, 4,4, 68.0],
And according to this question: numpy.VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
This has to do with the creation of arrays from lists of unequal length. So I presume that in this line:
[56.0, 0.0, 4,4, 68.0]
The 4,4 should have been a 4.4, right?
You first list has one more item (5 vs 4 for the others). This makes it an object array with python lists as elements (and you get a VisibleDeprecationWarning warning).
Thus cal becomes a concatenation of the lists ([56.0, 0.0, 4, 4, 68.0, 1.2, 104.0, 52.0, 8.0, 1.8, 135.0, 99.0, 0.9]) instead of a numpy array, triggering your error.
I imagine this might be a typo and changing 4,4 to 4.4 gives the following output:
A = np.array([[56.0, 0.0, 4.4, 68.0],
[1.2, 104.0, 52.0, 8.0],
[1.8, 135.0, 99.0, 0.9],])
cal = A.sum(axis=0)
# array([ 59. , 239. , 155.4, 76.9])
percentage = 100*A/cal.reshape(1,4)
print(percentage)
output:
[[94.91525424 0. 2.83140283 88.42652796]
[ 2.03389831 43.51464435 33.46203346 10.40312094]
[ 3.05084746 56.48535565 63.70656371 1.17035111]]
Use numpy.array to use shape attribute.
>>> import numpy as np
>>> X = np.array([
... [[-9.035250067710876], [7.453250169754028], [33.34074878692627]],
... [[-6.63700008392334], [5.132999956607819], [31.66075038909912]],
... [[-5.1272499561309814], [8.251499891281128], [30.925999641418457]]
... ])
>>> X.shape
(3L, 3L, 1L)
NOTE X.shape returns 3-items tuple for the given array; [n, T] = X.shape raises ValueError.
Alternatively, you can use np.shape(...)
For instance:
import numpy as np
a=[1,2,3]
and np.shape(a) will give an output of (3,)
Solution was linked on reshaped method on documentation page.
Insted of Y.reshape(-1,1) you need to use:
Y.values.reshape(-1,1)
The solution is indeed to do:
Y.values.reshape(-1,1)
This extracts a numpy array with the values of your pandas Series object and then reshapes it to a 2D array.
The reason you need to do this is that pandas Series objects are by design one dimensional. Another solution if you would like to stay within the pandas library would be to convert the Series to a DataFrame which would then be 2D:
Y = pd.Series([1,2,3,1,2,3,4,32,2,3,42,3])
scaler = StandardScaler()
Ys = scaler.fit_transform(pd.DataFrame(Y))
hello, i am relatively new to comfyui and found this ReActor node to swap faces. I tried it and got this error: NoneType object has no attribute reshape. I realy dont know how to fix this. I have reinstalled the ReActor node several times but nothing helped. I checked the dependencies and made sure everything is installed. I googled the error but found nothing. Please help. I am stuck at this for 2 weeks now.
[ReActor] 12:22:51 - STATUS - Checking for any unsafe content
[ReActor] 12:22:52 - STATUS - Working: source face index [0], target face index [0]
[ReActor] 12:22:52 - STATUS - Using Hashed Source Face(s) Model...
[ReActor] 12:22:52 - STATUS - Using Hashed Target Face(s) Model...
[ReActor] 12:22:52 - STATUS - Swapping...
!!! Exception during processing !!! 'NoneType' object has no attribute 'reshape'
Traceback (most recent call last):
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 345, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 220, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 192, in _map_node_over_list
process_inputs(input_dict, i)
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\ComfyUI\execution.py", line 181, in process_inputs
results.append(getattr(obj, func)(**inputs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-ReActor\nodes.py", line 373, in execute
script.process(
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-ReActor\scripts\reactor_faceswap.py", line 109, in process
result = swap_face(
^^^^^^^^^^
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-ReActor\scripts\reactor_swapper.py", line 362, in swap_face
result = face_swapper.get(result, target_face, source_face)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Programme\ComfyUI\ComfyUI_windows_portable\python_embeded\Lib\site-packages\insightface\model_zoo\inswapper.py", line 50, in get
latent = source_face.normed_embedding.reshape((1,-1))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'reshape'
Prompt executed in 0.54 seconds
This the consol log. I also looked in the files and asked Chatgpt but i couldnt find the problem.