Giter VIP home page Giter VIP logo

Comments (5)

JPW0080 avatar JPW0080 commented on June 15, 2024 1

Disregard, my placement of the suggested code was incorrect.

It works.

Thanks.

from stylegan-nada.

rinongal avatar rinongal commented on June 15, 2024

It looks like something is still loading on the CPU despite the availability of a GPU.

Could you try adding the following line to app.py right after the initialization of the e4e encoder (e.g. somewhere near line 122)?

self.e4e_net.to(self.device)

Basically it should now look something like this:

self.e4e_net = pSp(opts, self.device)
self.e4e_net.to(self.device)
self.e4e_net.eval()

from stylegan-nada.

JPW0080 avatar JPW0080 commented on June 15, 2024

The suggested edit/addition worked for all but the StyleCLIP option:

Anaconda3 Powershell Prompt:

conda activate chunkmogrify
cd C:\Anaconda3\envs\chunkmogrify\Lib\site-packages\StyleGAN-NADA

python app.py

Browser:
http://127.0.0.1:7860/

Image UL:
StyleCLIP
Edit image:

Aligned image has shape: (256, 256)
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:00<00:00, 19.80it/s]
Traceback (most recent call last):
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\gradio\routes.py", line 275, in predict
output = await app.blocks.process_api(body, username, session_state)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\gradio\blocks.py", line 274, in process_api
predictions = await run_in_threadpool(block_fn.fn, *processed_input)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\starlette\concurrency.py", line 39, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\anyio\to_thread.py", line 28, in run_sync
return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\anyio_backends_asyncio.py", line 818, in run_sync_in_worker_thread
return await future
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\anyio_backends_asyncio.py", line 754, in run
result = context.run(func, *args)
File "app.py", line 195, in inner
return func(self, *args, edit_choices)
File "app.py", line 232, in edit_image
return self.predict(input, output_styles, edit_choices=edit_choices)
File "app.py", line 267, in predict
img, _ = g_ema(latent_for_gen, input_is_s_code=True, input_is_latent=True, truncation=1, randomize_noise=False)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Anaconda3\envs\chunkmogrify\Lib\site-packages\StyleGAN-NADA\model\sg2_model.py", line 578, in forward
return self.forward_with_s(styles, return_latents, noise, randomize_noise)
File "C:\Anaconda3\envs\chunkmogrify\Lib\site-packages\StyleGAN-NADA\model\sg2_model.py", line 670, in forward_with_s
out = self.conv1(out, styles, is_s_code=True, noise=noise[0])
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Anaconda3\envs\chunkmogrify\Lib\site-packages\StyleGAN-NADA\model\sg2_model.py", line 381, in forward
out = self.conv(input, style, is_s_code=is_s_code)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "C:\Anaconda3\envs\chunkmogrify\Lib\site-packages\StyleGAN-NADA\model\sg2_model.py", line 275, in forward
weight = self.scale * self.weight * style
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

from stylegan-nada.

rinongal avatar rinongal commented on June 15, 2024

I won't have time to debug this until the weekend. If I had to guess from from looking at that log, you might be able to resolve this by explicitly moving the latents to the GPU, i.e. adding:

for layer in latent_for_gen:
    latent_for_gen[layer] = latent_for_gen[layer].cuda()

Just before like 267 in app.py.

I'll have a closer look during the weekend and see if I can track down the source of the problem.

from stylegan-nada.

JPW0080 avatar JPW0080 commented on June 15, 2024

Gave it a go:

Image UL:
StyleCLIP
Edit image:

Aligned image has shape: (256, 256)
Traceback (most recent call last):
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\gradio\routes.py", line 275, in predict
output = await app.blocks.process_api(body, username, session_state)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\gradio\blocks.py", line 274, in process_api
predictions = await run_in_threadpool(block_fn.fn, *processed_input)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\starlette\concurrency.py", line 39, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\anyio\to_thread.py", line 28, in run_sync
return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\anyio_backends_asyncio.py", line 818, in run_sync_in_worker_thread
return await future
File "C:\Anaconda3\envs\chunkmogrify\lib\site-packages\anyio_backends_asyncio.py", line 754, in run
result = context.run(func, *args)
File "app.py", line 195, in inner
return func(self, *args, edit_choices)
File "app.py", line 232, in edit_image
return self.predict(input, output_styles, edit_choices=edit_choices)
File "app.py", line 268, in predict
latent_for_gen[layer] = latent_for_gen[layer].cuda()
IndexError: tensors used as indices must be long, byte or bool tensors

from stylegan-nada.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.