Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

!python /content/DragGAN/visualizer_drag_gradio.py Problem #409

Open
seimuron1 opened this issue Nov 16, 2023 · 10 comments
Open

!python /content/DragGAN/visualizer_drag_gradio.py Problem #409

seimuron1 opened this issue Nov 16, 2023 · 10 comments

Comments

@seimuron1
Copy link

Hi. I have a problem to start the interface of DragGan AI after running command "!python /content/DragGAN/visualizer_drag_gradio.py" :

File under cache_dir (./checkpoints):
['stylegan2-cat-config-f.pkl', 'stylegan2_lions_512_pytorch.pkl', 'stylegan2-afhqcat-512x512.pkl', 'stylegan2-car-config-f.pkl', 'stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-ffhq-512x512.pkl', 'stylegan2_elephants_512_pytorch.pkl', 'stylegan2_horses_256_pytorch.pkl']
Valid checkpoint file:
{'stylegan2-cat-config-f': './checkpoints/stylegan2-cat-config-f.pkl', 'stylegan2_lions_512_pytorch': './checkpoints/stylegan2_lions_512_pytorch.pkl', 'stylegan2-afhqcat-512x512': './checkpoints/stylegan2-afhqcat-512x512.pkl', 'stylegan2-car-config-f': './checkpoints/stylegan2-car-config-f.pkl', 'stylegan2_dogs_1024_pytorch': './checkpoints/stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-ffhq-512x512': './checkpoints/stylegan2-ffhq-512x512.pkl', 'stylegan2_elephants_512_pytorch': './checkpoints/stylegan2_elephants_512_pytorch.pkl', 'stylegan2_horses_256_pytorch': './checkpoints/stylegan2_horses_256_pytorch.pkl'}
Loading "./checkpoints/stylegan2_lions_512_pytorch.pkl"... Done.
()
{'z_dim': 512, 'c_dim': 0, 'w_dim': 512, 'img_resolution': 512, 'img_channels': 3, 'mapping_kwargs': {'num_layers': 8, 'embed_features': None, 'layer_features': None, 'activation': 'lrelu', 'lr_multiplier': 0.01, 'w_avg_beta': 0.995}, 'synthesis_kwargs': {'channel_base': 32768, 'channel_max': 512, 'num_fp16_res': 0, 'conv_clamp': None, 'architecture': 'skip', 'resample_filter': [1, 3, 3, 1], 'use_noise': True, 'activation': 'lrelu'}}
Traceback (most recent call last):
File "/content/DragGAN/visualizer_drag_gradio.py", line 205, in
global_state = init_images(global_state)
File "/content/DragGAN/visualizer_drag_gradio.py", line 75, in init_images
state['renderer'].init_network(
File "/content/DragGAN/viz/renderer.py", line 224, in init_network
res.img_resolution = G.img_resolution
AttributeError: 'dict' object has no attribute 'img_resolution'

Also I was running the "!python scripts/download_model.py" command instead of "!sh scripts/download_model.sh".
Can someone help me? Im absolutely newbie in programming, just want to test this AI

Thanks

@rajnish159
Copy link

same issue😒😒

@woshixty
Copy link

me too

@woshixty
Copy link

I solved this problem!

  • pip install draggan
  • pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118
  • pip install Pillow==9.5.0
    After installing the above three software packages, you can run DragGAN normally.

@rajnish159
Copy link

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118
bro this is not working. please help me

@rajnish159
Copy link

I solved this problem!

thanks, this is properly working.

@OcheaDumi
Copy link

OcheaDumi commented Jan 20, 2024

Hello Everybod,
This did not get solved with the installation, I still face the same error

docker run -p 7860:7860 -v "$PWD":/workspace/src -it draggan:latest bash
root@a7ef1370a172:/workspace# cd src && python visualizer_drag_gradio.py --listen
File under cache_dir (./checkpoints):
['stylegan2-ffhq-512x512.pkl', 'stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-car-config-f.pkl', 'stylegan2_elephants_512_pytorch.pkl', 'stylegan2_lions_512_pytorch.pkl', 'stylegan2-cat-config-f.pkl', 'stylegan2-afhqcat-512x512.pkl', 'stylegan2_horses_256_pytorch.pkl']
Valid checkpoint file:
{'stylegan2-ffhq-512x512': './checkpoints/stylegan2-ffhq-512x512.pkl', 'stylegan2_dogs_1024_pytorch': './checkpoints/stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-car-config-f': './checkpoints/stylegan2-car-config-f.pkl', 'stylegan2_elephants_512_pytorch': './checkpoints/stylegan2_elephants_512_pytorch.pkl', 'stylegan2_lions_512_pytorch': './checkpoints/stylegan2_lions_512_pytorch.pkl', 'stylegan2-cat-config-f': './checkpoints/stylegan2-cat-config-f.pkl', 'stylegan2-afhqcat-512x512': './checkpoints/stylegan2-afhqcat-512x512.pkl', 'stylegan2_horses_256_pytorch': './checkpoints/stylegan2_horses_256_pytorch.pkl'}
Loading "./checkpoints/stylegan2_lions_512_pytorch.pkl"... Done.
()
{'z_dim': 512, 'c_dim': 0, 'w_dim': 512, 'img_resolution': 512, 'img_channels': 3, 'mapping_kwargs': {'num_layers': 8, 'embed_features': None, 'layer_features': None, 'activation': 'lrelu', 'lr_multiplier': 0.01, 'w_avg_beta': 0.995}, 'synthesis_kwargs': {'channel_base': 32768, 'channel_max': 512, 'num_fp16_res': 0, 'conv_clamp': None, 'architecture': 'skip', 'resample_filter': [1, 3, 3, 1], 'use_noise': True, 'activation': 'lrelu'}}
Traceback (most recent call last):
File "/workspace/src/visualizer_drag_gradio.py", line 205, in
global_state = init_images(global_state)
File "/workspace/src/visualizer_drag_gradio.py", line 75, in init_images
state['renderer'].init_network(
File "/workspace/src/viz/renderer.py", line 224, in init_network
res.img_resolution = G.img_resolution
AttributeError: 'dict' object has no attribute 'img_resolution'
root@a7ef1370a172:/workspace/src# # before you build the docker container, make sure you have cloned this repo, and downloaded the pretrained model by python scripts/download_model.py.
docker build . -t draggan:latest
docker run -p 7860:7860 -v "$PWD":/workspace/src -it draggan:latest bash
cd src && python visualizer_drag_gradio.py --listen
bash: docker: command not found
bash: docker: command not found
bash: cd: src: No such file or directory
root@a7ef1370a172:/workspace/src# python visualizer_drag_gradio.py
File under cache_dir (./checkpoints):
['stylegan2-ffhq-512x512.pkl', 'stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-car-config-f.pkl', 'stylegan2_elephants_512_pytorch.pkl', 'stylegan2_lions_512_pytorch.pkl', 'stylegan2-cat-config-f.pkl', 'stylegan2-afhqcat-512x512.pkl', 'stylegan2_horses_256_pytorch.pkl']
Valid checkpoint file:
{'stylegan2-ffhq-512x512': './checkpoints/stylegan2-ffhq-512x512.pkl', 'stylegan2_dogs_1024_pytorch': './checkpoints/stylegan2_dogs_1024_pytorch.pkl', 'stylegan2-car-config-f': './checkpoints/stylegan2-car-config-f.pkl', 'stylegan2_elephants_512_pytorch': './checkpoints/stylegan2_elephants_512_pytorch.pkl', 'stylegan2_lions_512_pytorch': './checkpoints/stylegan2_lions_512_pytorch.pkl', 'stylegan2-cat-config-f': './checkpoints/stylegan2-cat-config-f.pkl', 'stylegan2-afhqcat-512x512': './checkpoints/stylegan2-afhqcat-512x512.pkl', 'stylegan2_horses_256_pytorch': './checkpoints/stylegan2_horses_256_pytorch.pkl'}
Loading "./checkpoints/stylegan2_lions_512_pytorch.pkl"... Done.
()
{'z_dim': 512, 'c_dim': 0, 'w_dim': 512, 'img_resolution': 512, 'img_channels': 3, 'mapping_kwargs': {'num_layers': 8, 'embed_features': None, 'layer_features': None, 'activation': 'lrelu', 'lr_multiplier': 0.01, 'w_avg_beta': 0.995}, 'synthesis_kwargs': {'channel_base': 32768, 'channel_max': 512, 'num_fp16_res': 0, 'conv_clamp': None, 'architecture': 'skip', 'resample_filter': [1, 3, 3, 1], 'use_noise': True, 'activation': 'lrelu'}}
Traceback (most recent call last):
File "/workspace/src/visualizer_drag_gradio.py", line 205, in
global_state = init_images(global_state)
File "/workspace/src/visualizer_drag_gradio.py", line 75, in init_images
state['renderer'].init_network(
File "/workspace/src/viz/renderer.py", line 224, in init_network
res.img_resolution = G.img_resolution
AttributeError: 'dict' object has no attribute 'img_resolution'

Any ideas?

Thanks
I have tried to reinstall the docker all together, drivers, toolkit, the whole app from the beginning, it is the same outcome - if I run --gpus all it does not recognize gpu, if i run it without .... i get this error

@prajwalsingh
Copy link

Hi, if someone still has the problem, you can fix it by following:

Add/replace the following with code at line 70 in visualizer_drag_gradio

    if isinstance(global_state, gr.State):
        state = dnnlib.EasyDict(global_state.value)
    else:
        state = dnnlib.EasyDict(global_state)

    for key, item in state.items():
        if isinstance(item, dict):
            state[key] = dnnlib.EasyDict(item)

Add the following code before returning in function init_images (visualizer_drag_gradio):

global_state.value = state
return global_state

@dm4digitalmedia
Copy link

/unsubscribe

@Harry19s
Copy link

Harry19s commented May 7, 2024

when i run python visualizer_drag_gradio.py
report issue: AttributeError: 'dict' object has no attribute 'img_resolution
how do i solve this issue?

I don't know why but I solved this issue by

pip install gradio==3.36.1

this was also useful for pydantic error

@kriswangchunyan
Copy link

kriswangchunyan commented May 16, 2024

when i run python visualizer_drag_gradio.py
report issue: AttributeError: 'dict' object has no attribute 'img_resolution
how do i solve this issue?

I don't know why but I solved this issue by

pip install gradio==3.36.1

this was also useful for pydantic error

thanks,i solved this error and running now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants