Open script-money opened 1 year ago
Getting the same thing
I managed to run it with following modifications:
add map_location='cpu'
to all the torch.load
functions in:
1.1 pixelization/models/pixelization_model.py
1.2 pixelization/models/base_model.py
1.3 pixelization/models/c2pGen.py
1.4 scripts/postprocessing_pixelization.py
- 2 lines
Like this:
pixelization/models/pixelization_model.py: state_dict = torch.load(load_path, map_location='cpu')
pixelization/models/base_model.py: state_dict = torch.load(load_path, map_location='cpu')
pixelization/models/c2pGen.py: vgg19.load_state_dict(torch.load('./pixelart_vgg19.pth', map_location='cpu'))
scripts/postprocessing_pixelization.py: G_A_state = torch.load(path_160_net_G_A, map_location='cpu')
scripts/postprocessing_pixelization.py: alias_state = torch.load(path_alias_net, map_location='cpu')
Patch pixelization/models/networks.py
:
2.1 Comment CUDA availability check
2.2 Force DataParallel
function to use device 'cpu'
on line 113
Like this:
stable-diffusion-webui-pixelization % grep -B3 cpu pixelization/models/networks.py
if len(gpu_ids) > 0:
# assert(torch.cuda.is_available())
# net.to(gpu_ids[0])
net = torch.nn.DataParallel(net, 'cpu') # multi-GPUs
stable-diffusion-webui-pixelization %
Restart webui.sh
and Pixelize.
Enjoy.
I modified the files and it now generates images, just not as expected:
I am also having the same problem.
I managed to run it with following modifications:
- add
map_location='cpu'
to all thetorch.load
functions in: 1.1pixelization/models/pixelization_model.py
1.2pixelization/models/base_model.py
1.3pixelization/models/c2pGen.py
1.4scripts/postprocessing_pixelization.py
- 2 lines Like this:pixelization/models/pixelization_model.py: state_dict = torch.load(load_path, map_location='cpu') pixelization/models/base_model.py: state_dict = torch.load(load_path, map_location='cpu') pixelization/models/c2pGen.py: vgg19.load_state_dict(torch.load('./pixelart_vgg19.pth', map_location='cpu')) scripts/postprocessing_pixelization.py: G_A_state = torch.load(path_160_net_G_A, map_location='cpu') scripts/postprocessing_pixelization.py: alias_state = torch.load(path_alias_net, map_location='cpu')
- Patch
pixelization/models/networks.py
: 2.1 Comment CUDA availability check 2.2 ForceDataParallel
function to use device'cpu'
on line113
Like this:
stable-diffusion-webui-pixelization % grep -B3 cpu pixelization/models/networks.py if len(gpu_ids) > 0: # assert(torch.cuda.is_available()) # net.to(gpu_ids[0]) net = torch.nn.DataParallel(net, 'cpu') # multi-GPUs stable-diffusion-webui-pixelization %
- Restart
webui.sh
and Pixelize.Enjoy.
I tried altering the files exactly as you described, after a complete restart of Automatic1111 and terminal, the pixelation option disappear's from the webui (in the extras tab). Any idea what's happening or what I can do to get it to run (on an M1 Mac)?
I managed to run it with following modifications:
- add
map_location='cpu'
to all thetorch.load
functions in: 1.1pixelization/models/pixelization_model.py
1.2pixelization/models/base_model.py
1.3pixelization/models/c2pGen.py
1.4scripts/postprocessing_pixelization.py
- 2 lines Like this:pixelization/models/pixelization_model.py: state_dict = torch.load(load_path, map_location='cpu') pixelization/models/base_model.py: state_dict = torch.load(load_path, map_location='cpu') pixelization/models/c2pGen.py: vgg19.load_state_dict(torch.load('./pixelart_vgg19.pth', map_location='cpu')) scripts/postprocessing_pixelization.py: G_A_state = torch.load(path_160_net_G_A, map_location='cpu') scripts/postprocessing_pixelization.py: alias_state = torch.load(path_alias_net, map_location='cpu')
- Patch
pixelization/models/networks.py
: 2.1 Comment CUDA availability check 2.2 ForceDataParallel
function to use device'cpu'
on line113
Like this:
stable-diffusion-webui-pixelization % grep -B3 cpu pixelization/models/networks.py if len(gpu_ids) > 0: # assert(torch.cuda.is_available()) # net.to(gpu_ids[0]) net = torch.nn.DataParallel(net, 'cpu') # multi-GPUs stable-diffusion-webui-pixelization %
- Restart
webui.sh
and Pixelize.Enjoy.
This worked perfectly for me, Thanks!
I could not get it to work this way Did the code change?
Is it possible to run on CPU?