Giter Club home page Giter Club logo

opengvlab / draggan Goto Github PK

View Code? Open in Web Editor NEW
5.0K 66.0 491.0 8.03 MB

Unofficial Implementation of DragGAN - "Drag Your GAN: Interactive Point-based Manipulation on the Generative Image Manifold" (DragGAN 全功能实现,在线Demo,本地部署试用,代码、模型已全部开源,支持Windows, macOS, Linux)

Python 87.18% C++ 3.21% Cuda 9.17% Jupyter Notebook 0.41% Dockerfile 0.04%
draggan image-editing image-generation gradio-interface interngpt

draggan's People

Contributors

azhuge233 avatar dependabot[bot] avatar egbaydarov avatar egorbajdarov avatar eltociear avatar iamrajee avatar liu-zhy avatar marwanmusa avatar snoopydevelops avatar thuliu-yt16 avatar zeqiang-lai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

draggan's Issues

[Bug Fixed] RuntimeError: Ninja is required to load C++ extensions

(pytorch) [cyy@localhost draggan]$ python gradio_app.py
Traceback (most recent call last):
  File "/code/draggan/gradio_app.py", line 6, in <module>
    from drag_gan import drag_gan, stylegan2
  File "/code/draggan/drag_gan.py", line 12, in <module>
    from stylegan2.model import Generator
  File "/code/draggan/stylegan2/model.py", line 8, in <module>
    from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
  File "/code/draggan/stylegan2/op/__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/code/draggan/stylegan2/op/fused_act.py", line 11, in <module>
    fused = load(
  File "anaconda/envs/pytorch/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1144, in load
    return _jit_compile(
  File "/env/anaconda/envs/pytorch/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1357, in _jit_compile
    _write_ninja_file_and_build_library(
  File "/env/anaconda/envs/pytorch/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1438, in _write_ninja_file_and_build_library
    verify_ninja_availability()
  File "/env/anaconda/envs/pytorch/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1494, in verify_ninja_availability
    raise RuntimeError("Ninja is required to load C++ extensions")
RuntimeError: Ninja is required to load C++ extensions

ninja: build stopped: subcommand failed.,how to fix it| Ubuntu 22.04

ubuntu@ubuntu:~/DragGAN$ python3 gradio_app.py
Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1893, in _run_ninja_build
subprocess.run(
File "/usr/lib/python3.10/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/ubuntu/DragGAN/gradio_app.py", line 9, in
from drag_gan import drag_gan, stylegan2
File "/home/ubuntu/DragGAN/drag_gan.py", line 12, in
from stylegan2.model import Generator
File "/home/ubuntu/DragGAN/stylegan2/model.py", line 8, in
from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
File "/home/ubuntu/DragGAN/stylegan2/op/init.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "/home/ubuntu/DragGAN/stylegan2/op/fused_act.py", line 11, in
fused = load(
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1284, in load
return jit_compile(
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1509, in jit_compile
write_ninja_file_and_build_library(
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1624, in write_ninja_file_and_build_library
run_ninja_build(
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 1909, in run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error building extension 'fused': [1/2] /usr/local/cuda/bin/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1011" -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include/TH -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include/THC -isystem /usr/local/cuda/bin/include -isystem /usr/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS
-D__CUDA_NO_BFLOAT16_CONVERSIONS
-D__CUDA_NO_HALF2_OPERATORS
--expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++17 -c /home/ubuntu/DragGAN/stylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
FAILED: fused_bias_act_kernel.cuda.o
/usr/local/cuda/bin/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1011" -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include/TH -isystem /home/ubuntu/.local/lib/python3.10/site-packages/torch/include/THC -isystem /usr/local/cuda/bin/include -isystem /usr/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS
-D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++17 -c /home/ubuntu/DragGAN/stylegan2/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
/bin/sh: 1: /usr/local/cuda/bin/bin/nvcc: not found
ninja: build stopped: subcommand failed.

Out of memory error

I can open the web and set blue and red point. But after I click "drag it", it shows "error", in Anaconda prompt, the error message is:
"torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 512.00 MiB (GPU 0; 4.00 GiB total capacity; 3.07 GiB already allocated; 0 bytes free; 3.26 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF"

企业微信截图_16850877962092

Cannot use custom image

The tool is nice, but does not work with custom image yet.

  1. get error when uploaded image is not in size 1024*1024
  2. will automatically change back to the demo image when "drag it" is clicked

Nvidia Only ?

I am trying to use but I get this error:

python gradio_app.py
C:\Program Files\Python39\lib\site-packages\torch\utils\cpp_extension.py:358: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
  warnings.warn(f'Error checking compiler version for {compiler}: {error}')
Traceback (most recent call last):
  File "E:\000000000\DragGAN-main\gradio_app.py", line 9, in <module>
    from drag_gan import drag_gan, stylegan2
  File "E:\000000000\DragGAN-main\drag_gan.py", line 12, in <module>
    from stylegan2.model import Generator
  File "E:\000000000\DragGAN-main\stylegan2\model.py", line 8, in <module>
    from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
  File "E:\000000000\DragGAN-main\stylegan2\op\__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "E:\000000000\DragGAN-main\stylegan2\op\fused_act.py", line 11, in <module>
    fused = load(
  File "C:\Program Files\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1284, in load
    return _jit_compile(
  File "C:\Program Files\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1508, in _jit_compile
    _write_ninja_file_and_build_library(
  File "C:\Program Files\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1600, in _write_ninja_file_and_build_library
    extra_ldflags = _prepare_ldflags(
  File "C:\Program Files\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 1703, in _prepare_ldflags
    extra_ldflags.append(f'/LIBPATH:{_join_cuda_home("lib", "x64")}')
  File "C:\Program Files\Python39\lib\site-packages\torch\utils\cpp_extension.py", line 2230, in _join_cuda_home
    raise EnvironmentError('CUDA_HOME environment variable is not set. '
OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

Can you tell us if is a NVIDIA GPU is necessary to use DragGan ?

Which torch is supported?

(DRAGGANTEST) C:\Users\Duckers\Downloads\DragGAN-main>python gradio_app.py
stylegan2-ffhq-config-f.pt not found
Try to download from huggingface: https://huggingface.co/aaronb/StyleGAN2/resolve/main/stylegan2-ffhq-config-f.pt
stylegan2-ffhq-config-f.pt: 133MB [00:02, 47.1MB/s]
Downloaded to checkpoints\stylegan2-ffhq-config-f.pt
C:\Users\Duckers\Downloads\DragGAN-main\stylegan2\op\conv2d_gradfix.py:88: UserWarning: conv2d_gradfix not supported on PyTorch 2.0.1. Falling back to torch.nn.functional.conv2d().
warnings.warn(

As conv2d isn't supported on pytorch 2.0.1. I can generate, but not save.

DLL load failed

I got error with cpp_extension.py

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 5
      2 sys.path.append(".")
      3 sys.path.append('[./DragGAN](https://file+.vscode-resource.vscode-cdn.net/f%3A/MyFile/DragGAN/DragGAN)')
----> 5 from gradio_app import main

File [f:\MyFile\DragGAN\gradio_app.py:9](file:///F:/MyFile/DragGAN/gradio_app.py:9)
      6 from PIL import Image
      7 import uuid
----> 9 from drag_gan import drag_gan, stylegan2
     11 device = 'cuda'
     14 SIZE_TO_CLICK_SIZE = {
     15     1024: 5,
     16     256: 2
     17 }

File [f:\MyFile\DragGAN\drag_gan.py:12](file:///F:/MyFile/DragGAN/drag_gan.py:12)
      9 from torchvision import utils
     10 from tqdm import tqdm
---> 12 from stylegan2.model import Generator
     15 class DownloadProgressBar(tqdm):
     16     def update_to(self, b=1, bsize=1, tsize=None):

File [f:\MyFile\DragGAN\stylegan2\model.py:8](file:///F:/MyFile/DragGAN/stylegan2/model.py:8)
      5 from torch import nn
      6 from torch.nn import functional as F
----> 8 from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
     11 class PixelNorm(nn.Module):
     12     def __init__(self):

File [f:\MyFile\DragGAN\stylegan2\op\__init__.py:1](file:///F:/MyFile/DragGAN/stylegan2/op/__init__.py:1)
----> 1 from .fused_act import FusedLeakyReLU, fused_leaky_relu
      2 from .upfirdn2d import upfirdn2d

File [f:\MyFile\DragGAN\stylegan2\op\fused_act.py:11](file:///F:/MyFile/DragGAN/stylegan2/op/fused_act.py:11)
      7 from torch.utils.cpp_extension import load
     10 module_path = os.path.dirname(__file__)
---> 11 fused = load(
     12     "fused",
     13     sources=[
     14         os.path.join(module_path, "fused_bias_act.cpp"),
     15         os.path.join(module_path, "fused_bias_act_kernel.cu"),
     16     ],
     17 )
     20 class FusedLeakyReLUFunctionBackward(Function):
     21     @staticmethod
     22     def forward(ctx, grad_output, out, bias, negative_slope, scale):

File [f:\MyFile\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py:1284](file:///F:/MyFile/DragGAN/venv/lib/site-packages/torch/utils/cpp_extension.py:1284), in load(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda, is_python_module, is_standalone, keep_intermediates)
   1192 def load(name,
   1193          sources: Union[str, List[str]],
   1194          extra_cflags=None,
   (...)
   1202          is_standalone=False,
   1203          keep_intermediates=True):
   1204     r'''
   1205     Loads a PyTorch C++ extension just-in-time (JIT).
   1206 
   (...)
   1282         ...     verbose=True)
   1283     '''
-> 1284     return _jit_compile(
   1285         name,
   1286         [sources] if isinstance(sources, str) else sources,
   1287         extra_cflags,
   1288         extra_cuda_cflags,
   1289         extra_ldflags,
   1290         extra_include_paths,
   1291         build_directory or _get_build_directory(name, verbose),
   1292         verbose,
   1293         with_cuda,
   1294         is_python_module,
   1295         is_standalone,
   1296         keep_intermediates=keep_intermediates)

File [f:\MyFile\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py:1535](file:///F:/MyFile/DragGAN/venv/lib/site-packages/torch/utils/cpp_extension.py:1535), in _jit_compile(name, sources, extra_cflags, extra_cuda_cflags, extra_ldflags, extra_include_paths, build_directory, verbose, with_cuda, is_python_module, is_standalone, keep_intermediates)
   1532 if is_standalone:
   1533     return _get_exec_path(name, build_directory)
-> 1535 return _import_module_from_library(name, build_directory, is_python_module)

File [f:\MyFile\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py:1929](file:///F:/MyFile/DragGAN/venv/lib/site-packages/torch/utils/cpp_extension.py:1929), in _import_module_from_library(module_name, path, is_python_module)
   1927 spec = importlib.util.spec_from_file_location(module_name, filepath)
   1928 assert spec is not None
-> 1929 module = importlib.util.module_from_spec(spec)
   1930 assert isinstance(spec.loader, importlib.abc.Loader)
   1931 spec.loader.exec_module(module)

ImportError: DLL load failed while importing fused: The specified module could not be found.

previously, I got this error

CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

then, I try to change ['ninja', '-v'] to ['ninja', '--version'] (got this solution while exploring on stackoverflow) .
and then, this Error : *DLL load failed* show up.

Can anybody help with this?

Failed to load Torch extension

Followed instructions for WSL:

(draggan) perplexity@Perplexity:~/DragGAN$ python -m draggan.web
/home/perplexity/DragGAN/draggan/stylegan2/op/fused_act.py:22: UserWarning: Fail to build torch extension, switch to native implementation
warnings.warn(
/home/perplexity/DragGAN/draggan/stylegan2/op/upfirdn2d.py:21: UserWarning: Fail to build torch extension, switch to native implementation
warnings.warn(
stylegan2-ffhq-config-f.pt not found
Try to download from huggingface: https://huggingface.co/aaronb/StyleGAN2/resolve/main/stylegan2-ffhq-config-f.pt
stylegan2-ffhq-config-f.pt: 133MB [00:01, 97.3MB/s]
Downloaded to /home/perplexity/draggan/checkpoints/stylegan2-ffhq-config-f.pt
Running on local URL: http://127.0.0.1:7860

AssertionError: Torch not compiled with CUDA enabled

Hi, I'm trying to run DragGAN but I got this message error:

To create a public link, set share=Trueinlaunch(). Traceback (most recent call last): File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\gradio\routes.py", line 406, in run_predict event_data=event_data, File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\gradio\blocks.py", line 1300, in process_api fn_index, inputs, iterator, request, event_id, event_data File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\gradio\blocks.py", line 1037, in call_function utils.async_iteration, iterator, limiter=self.limiter File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\anyio\to_thread.py", line 32, in run_sync func, *args, cancellable=cancellable, limiter=limiter File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread return await future File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run result = context.run(func, *args) File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\gradio\utils.py", line 488, in async_iteration return next(iterator) File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\draggan\web.py", line 135, in on_drag max_iters=max_iters): File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\draggan\api.py", line 191, in drag_gan for qi in neighbor(int(pi[0]), int(pi[1]), r1): File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\draggan\api.py", line 171, in neighbor points.append(torch.tensor([i, j]).float().cuda()) File "C:\Users\Lucas Lima\miniconda3\envs\draggan\lib\site-packages\torch\cuda\__init__.py", line 221, in _lazy_init raise AssertionError("Torch not compiled with CUDA enabled") AssertionError: Torch not compiled with CUDA enabled

I have AMD Radeon RX 590
Does anyone knows what about it?

Fused extension build error

RuntimeError: Error building extension 'fused': [1/3] c++ -MMD -MF fused_bias_act.o.d -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="_gcc" -DPYBIND11_STDLIB="_libstdcpp" -DPYBIND11_BUILD_ABI="_cxxabi1011" -isystem /home/kris/.local/lib/python3.10/site-packages/torch/include -isystem /home/kris/.local/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem /home/kris/.local/lib/python3.10/site-packages/torch/include/TH -isystem /home/kris/.local/lib/python3.10/site-packages/torch/include/THC -isystem /usr/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++14 -c /mnt/c/users/admin/desktop/DragGAN/stylegan2/op/fused_bias_act.cpp -o fused_bias_act.o

under win 10 wsl ubuntu vm
but I also get similar error when I try directly on win 10

Requirements Error

Running python gradio_app.py I get the following stack trace, any suggestions?

Traceback (most recent call last):
  File "/Users/dylanrae/Documents/GitHub/DragGAN/gradio_app.py", line 9, in <module>
    from drag_gan import drag_gan, stylegan2
  File "/Users/dylanrae/Documents/GitHub/DragGAN/drag_gan.py", line 9, in <module>
    from torchvision import utils
  File "/Users/dylanrae/.pyenv/versions/3.10.6/lib/python3.10/site-packages/torchvision/__init__.py", line 6, in <module>
    from torchvision import datasets, io, models, ops, transforms, utils
  File "/Users/dylanrae/.pyenv/versions/3.10.6/lib/python3.10/site-packages/torchvision/datasets/__init__.py", line 1, in <module>
    from ._optical_flow import FlyingChairs, FlyingThings3D, HD1K, KittiFlow, Sintel
  File "/Users/dylanrae/.pyenv/versions/3.10.6/lib/python3.10/site-packages/torchvision/datasets/_optical_flow.py", line 13, in <module>
    from .utils import _read_pfm, verify_str_arg
  File "/Users/dylanrae/.pyenv/versions/3.10.6/lib/python3.10/site-packages/torchvision/datasets/utils.py", line 6, in <module>
    import lzma
  File "/Users/dylanrae/.pyenv/versions/3.10.6/lib/python3.10/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

gradio_app.py error

I tried to run gradio_app.py, but error has occurred.

There are only black points, no red and blue point.
The error image is as follows.

Screenshot from 2023-05-23 10-29-18

IndexError: list index out of range

while I select two points and press drag it

Traceback (most recent call last):
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/gradio/routes.py", line 414, in run_predict
    output = await app.get_blocks().process_api(
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/gradio/blocks.py", line 1320, in process_api
    result = await self.call_function(
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/gradio/blocks.py", line 1064, in call_function
    prediction = await utils.async_iteration(iterator)
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/gradio/utils.py", line 514, in async_iteration
    return await iterator.__anext__()
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/gradio/utils.py", line 507, in __anext__
    return await anyio.to_thread.run_sync(
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/data/miniconda3/envs/env-novelai/lib/python3.10/site-packages/gradio/utils.py", line 490, in run_sync_iterator_async
    return next(iterator)
  File "/group/20000/ramseyhuang/DragGAN/gradio_app.py", line 39, in on_drag
    for sample2, latent, F in drag_gan(g_ema, latent, noise, F,
  File "/group/20000/ramseyhuang/DragGAN/drag_gan.py", line 189, in drag_gan
    pi, ti = handle_points[i], target_points[i]
IndexError: list index out of range

And my gradio page is different with the one in demo.mp4
image

After I try the online demo follow the demo.mp4 steps, also raise error

Uploading image.png…

Cuda

Is there anywhere pointing out Cuda/Cudnn Version requirements? Any chance of a workaround for using AMD GPU at these early stages?

无法正常显示图片

在本地部署时 遇到了gradio app中无法正常显示图片的问题,只显示一张纯色(橘色)图片,使用new image换图也无法解决这个问题,期待您的帮助
图片

colab error

I tried to run colab, but an error occurred.

There is no blue point and red point, so I can't drag it.
The colab image is as follows:

Screenshot from 2023-05-23 10-01-29

Error launching after installing requirements

Not sure what exactly this means, all the requirements installed correctly.

python gradio_app.py
No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1'
D:\AIModels\Art\GAN\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py:359: UserWarning: Error checking compiler version for cl: [WinError 2] The system cannot find the file specified
  warnings.warn(f'Error checking compiler version for {compiler}: {error}')
Traceback (most recent call last):
  File "D:\AIModels\Art\GAN\DragGAN\gradio_app.py", line 9, in <module>
    from drag_gan import drag_gan, stylegan2
  File "D:\AIModels\Art\GAN\DragGAN\drag_gan.py", line 12, in <module>
    from stylegan2.model import Generator
  File "D:\AIModels\Art\GAN\DragGAN\stylegan2\model.py", line 8, in <module>
    from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
  File "D:\AIModels\Art\GAN\DragGAN\stylegan2\op\__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "D:\AIModels\Art\GAN\DragGAN\stylegan2\op\fused_act.py", line 11, in <module>
    fused = load(
  File "D:\AIModels\Art\GAN\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py", line 1284, in load
    return _jit_compile(
  File "D:\AIModels\Art\GAN\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py", line 1509, in _jit_compile
    _write_ninja_file_and_build_library(
  File "D:\AIModels\Art\GAN\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py", line 1611, in _write_ninja_file_and_build_library
    _write_ninja_file_to_build_library(
  File "D:\AIModels\Art\GAN\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py", line 2007, in _write_ninja_file_to_build_library
    cuda_flags = common_cflags + COMMON_NVCC_FLAGS + _get_cuda_arch_flags()
  File "D:\AIModels\Art\GAN\DragGAN\venv\lib\site-packages\torch\utils\cpp_extension.py", line 1773, in _get_cuda_arch_flags
    arch_list[-1] += '+PTX'
IndexError: list index out of range

different framework

I saw DragGAN on the twitter as the below image.

Screenshot from 2023-05-23 16-59-47
Screenshot from 2023-05-23 17-04-54
Screenshot from 2023-05-23 17-07-40

I think the framework of the twitter is different from this one.
Is that so?

Woman face collapsed after rotation

I run the woman face rotation, but the final face was collapsed as the following image.
Especially, around the left eye is blue, the nose is big.

Screenshot from 2023-05-23 15-53-37

ImportError: /root/.cache/torch_extensions/py310_cu117/fused/fused.so

WARNING: Ignoring invalid distribution -orch (/usr/local/lib/python3.10/dist-packages)

ImportError Traceback (most recent call last)
in <cell line: 10>()
8 get_ipython().system('pip install -r DragGAN/requirements.txt')
9
---> 10 from gradio_app import main

7 frames
/usr/local/lib/python3.10/dist-packages/torch/utils/cpp_extension.py in _import_module_from_library(module_name, path, is_python_module)
1934 spec = importlib.util.spec_from_file_location(module_name, filepath)
1935 assert spec is not None
-> 1936 module = importlib.util.module_from_spec(spec)
1937 assert isinstance(spec.loader, importlib.abc.Loader)
1938 spec.loader.exec_module(module)

ImportError: /root/.cache/torch_extensions/py310_cu117/fused/fused.so: cannot open shared object file: No such file or directory

I tried different pytorch version with no success

RuntimeError: Ninja is required to load C++ extensions

Hello and I found an error, I made on google colab created on your work github and I get the error like this:

/content/DragGAN
Traceback (most recent call last):
File "/content/DragGAN/gradio_app.py", line 3, in
from drag_gan import stylegan2, drag_gan
File "/content/DragGAN/drag_gan.py", line 12, in
from stylegan2.model import Generator
File "/content/DragGAN/stylegan2/model.py", line 8, in
from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
File "/content/DragGAN/stylegan2/op/init.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "/content/DragGAN/stylegan2/op/fused_act.py", line 11, in
fused = load(
File "/usr/local/lib/python3.10/dist-packages/torch/utils/cpp_extension.py", line 1284, in load
return _jit_compile(
File "/usr/local/lib/python3.10/dist-packages/torch/utils/cpp_extension.py", line 1509, in _jit_compile
_write_ninja_file_and_build_library(
File "/usr/local/lib/python3.10/dist-packages/torch/utils/cpp_extension.py", line 1593, in _write_ninja_file_and_build_library
verify_ninja_availability()
File "/usr/local/lib/python3.10/dist-packages/torch/utils/cpp_extension.py", line 1649, in verify_ninja_availability
raise RuntimeError("Ninja is required to load C++ extensions")
RuntimeError: Ninja is required to load C++ extensions

the question is, can you fix it? if you have fixed it then, many thanks for the conversation. thx

RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

(draggan) PS D:> python -m draggan.web
C:\Users\sam.conda\envs\draggan\lib\site-packages\torch\utils\cpp_extension.py:358: UserWarning: Error checking compiler version for cl: [WinError 2]
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
C:\Users\sam.conda\envs\draggan\lib\site-packages\draggan\stylegan2\op\fused_act.py:23: UserWarning: (This is not error) Switch to native implementation
f"(This is not error) Switch to native implementation"
C:\Users\sam.conda\envs\draggan\lib\site-packages\draggan\stylegan2\op\upfirdn2d.py:22: UserWarning: (This is not error) Switch to native implementation
f"(This is not error) Switch to native implementation"
Traceback (most recent call last):
File "C:\Users\sam.conda\envs\draggan\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\sam.conda\envs\draggan\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\sam.conda\envs\draggan\lib\site-packages\draggan\web.py", line 346, in
demo = main()
File "C:\Users\sam.conda\envs\draggan\lib\site-packages\draggan\web.py", line 241, in main
wrapped_model = ModelWrapper(ckpt=DEFAULT_CKPT, size=CKPT_SIZE[DEFAULT_CKPT])
File "C:\Users\sam.conda\envs\draggan\lib\site-packages\draggan\web.py", line 78, in init
self.g_ema = stylegan2(**kwargs).to(device)
File "C:\Users\sam.conda\envs\draggan\lib\site-packages\draggan\api.py", line 126, in stylegan2
checkpoint = torch.load(get_path(ckpt))
File "C:\Users\sam.conda\envs\draggan\lib\site-packages\torch\serialization.py", line 777, in load
with _open_zipfile_reader(opened_file) as opened_zipfile:
File "C:\Users\sam.conda\envs\draggan\lib\site-packages\torch\serialization.py", line 282, in init
super(_open_zipfile_reader, self).init(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory

follow the PyPI install instructions,get runtime error

ERROR: No matching distribution found for draggan

windows 11, can't install draggan.
error below:
command is : (draggan) C:\Users\Administrator>pip install draggan
ERROR: Could not find a version that satisfies the requirement draggan (from versions: none)
ERROR: No matching distribution found for draggan

use cpu to inference

when I change the "device" in gradio_app.py from cuda to cpu,it raises error "expect all tensors on the same device".

very slow

I'm on RTX4090, to drag a face generated by default config. One step will take about 1s, is this normal or it's just what this model is now?

_get_cuda_arch_flags() error

Have everything properly installed but get this issue both in the notebook and on local version

line 1773, in _get_cuda_arch_flags
arch_list[-1] += '+PTX'
~~~~~~~~~^^^^
IndexError: list index out of range

DLL load failed while importing fused: The specified module could not be found.

Can it work with Torch2.0 or does it use functions that aren't present in 2.0? (that is what I suspect at first glance)
I tried and I get "DLL load failed while importing fused: The specified module could not be found."

# Error: DLL load failed while importing fused: The specified module could not be found.
# # Traceback (most recent call last):
# #   File "<maya console>", line 1, in <module>
# #   File "Z:\MAYA_AI\plugin\python\drag_gan.py", line 12, in <module>
# #     from stylegan2.model import Generator
# #   File "Z:\MAYA_AI\plugin\python\stylegan2\model.py", line 8, in <module>
# #     from .op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
# #   File "Z:\MAYA_AI\plugin\python\stylegan2\op\__init__.py", line 1, in <module>
# #     from .fused_act import FusedLeakyReLU, fused_leaky_relu
# #   File "Z:\MAYA_AI\plugin\python\stylegan2\op\fused_act.py", line 11, in <module>
# #     fused = load(
# #   File "C:\Users\pj\AppData\Roaming\Python\Python39\site-packages\torch\utils\cpp_extension.py", line 1284, in load
# #     return _jit_compile(
# #   File "C:\Users\pj\AppData\Roaming\Python\Python39\site-packages\torch\utils\cpp_extension.py", line 1535, in _jit_compile
# #     return _import_module_from_library(name, build_directory, is_python_module)
# #   File "C:\Users\pj\AppData\Roaming\Python\Python39\site-packages\torch\utils\cpp_extension.py", line 1929, in _import_module_from_library
# #     module = importlib.util.module_from_spec(spec)
# # ImportError: DLL load failed while importing fused: The specified module could not be found.

Lion head didn't move and mouth didn't open.

I tried to move lion head front to side and open the mouth like the example of this repository.
But, lion head didn't move and mouth didn't open, as the following image.
Moreover, the lion face distorted badly.

Screenshot from 2023-05-23 14-07-30

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.