Comments (5)
Disregard, my placement of the suggested code was incorrect.
It works.
Thanks.
from stylegan-nada.
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.
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.
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.
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)
- Gradio related inquiry HOT 1
- Question about specifying the style HOT 4
- About the bug when running Demo HOT 7
- Style transfer of "White Walker" HOT 1
- How to use style mapper HOT 1
- A specific domain changes in global direction HOT 1
- Sample Code for retraining OASIS HOT 2
- Control eye position HOT 2
- Question about gradient of transforms HOT 2
- Unexpexted output when providing randomly sampled latents HOT 1
- clip_model_weights and auto_layer_k HOT 3
- Nvidia error when running docker-compose up HOT 1
- Cross-domain image interpolation HOT 3
- When choose other than 'ffhq' for source model type
- i want to add eyeglasses boundary from stylegan ffhq . HOT 1
- unauthorized: authentication required on docker compose up
- Ajout de nouvelle couche dans le modèle de stylegan_nada(transfert learning)
- image2image
- Migration with a specific content image HOT 5
- Performance Metric Missing HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stylegan-nada.