It is possible to return a value of type None, check the type of X_train in the following lines:
CopyX_train = X_train.resize((32, 32))
type(X_train)
X_train = X_train.reshape((len(X_train), 3, 32, 32))
type(X_train)
Answer from Leonid Dubrovin on Stack OverflowIt is possible to return a value of type None, check the type of X_train in the following lines:
CopyX_train = X_train.resize((32, 32))
type(X_train)
X_train = X_train.reshape((len(X_train), 3, 32, 32))
type(X_train)
only the type of array can use reshape() and it can not change the number of the data your array contains. Maybe you can try something like this:
Copyimport numpy as np
from PIL import Image
import matplotlib as plt
x_train = Image.open('skyscraper.jpg')
x_train = x_train.resize((32,32))
x_train = np.array(x_train)
x_train = x_train.reshape((3,32,32))
print(x_train)
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.
python - AttributeError: 'Series' object has no attribute 'reshape' - Stack Overflow
python 3.x - AttributeError: 'list' object has no attribute 'reshape' when using reshape for a list - Stack Overflow
python - Seaborn Heatmap Error: " AttributeError: 'NoneType' object has no attribute 'reshape' " - Stack Overflow
AttributeError: 'NoneType' object has no attribute 'shape'
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))
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))
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
I used the ControlNet extension & the Realistic Vision checkpoint, and it keeps giving me this error, "AttributeError: 'NoneType' object has no attribute 'shape'" whenever I try to generate a image. Even not using them, I still get this error.
What is the issue and how can I fix it?
Edit: it turns out when trying to use ControlNet, I was matching one of the preprocessors with the wrong models.