Giter Club home page Giter Club logo

dct-net's Introduction

DCT-Net: Domain-Calibrated Translation for Portrait Stylization

Official implementation of DCT-Net for Full-body Portrait Stylization.

DCT-Net: Domain-Calibrated Translation for Portrait Stylization,
Yifang Men1, Yuan Yao1, Miaomiao Cui1, Zhouhui Lian2, Xuansong Xie1,
1DAMO Academy, Alibaba Group, Beijing, China
2Wangxuan Institute of Computer Technology, Peking University, China
In: SIGGRAPH 2022 (TOG) arXiv preprint

google colab logo Hugging Face Spaces

Demo

demo

News

(2023-03-14) The training guidance has been released, train DCT-Net with your own style data.

(2023-02-20) Two new style pre-trained models (design, illustration) trained with combined DCT-Net and Stable-Diffusion are provided. The training guidance will be released soon.

(2022-10-09) The multi-style pre-trained models (3d, handdrawn, sketch, artstyle) and usage are available now.

(2022-08-08) The pertained model and infer code of 'anime' style is available now. More styles coming soon.

(2022-08-08) cartoon function can be directly call from pythonSDK.

(2022-07-07) The paper is available now at arxiv(https://arxiv.org/abs/2207.02426).

Web Demo

Requirements

  • python 3
  • tensorflow (>=1.14, training only support tf1.x)
  • easydict
  • numpy
  • both CPU/GPU are supported

Quick Start

google colab logo

git clone https://github.com/menyifang/DCT-Net.git
cd DCT-Net

Installation

conda create -n dctnet python=3.7
conda activate dctnet
pip install --upgrade tensorflow-gpu==1.15 # GPU support, use tensorflow for CPU only
pip install "modelscope[cv]==1.3.2" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
pip install "modelscope[multi-modal]==1.3.2" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

Downloads

anime 3d handdrawn sketch artstyle
design illustration

Pre-trained models in different styles can be downloaded by

python download.py

Inference

  • from python SDK
python run_sdk.py
  • from source code
python run.py

Video cartoonization

demo_vid

video can be directly processed as image sequences, style choice [option: anime, 3d, handdrawn, sketch, artstyle, sd-design, sd-illustration]

python run_vid.py --style anime

Training

google colab logo

Data preparation

face_photo: face dataset such as [FFHQ](https://github.com/NVlabs/ffhq-dataset) or other collected real faces.
face_cartoon: 100-300 cartoon face images in a specific style, which can be self-collected or synthsized with generative models.

Due to the copyrighe issues, we can not provide collected cartoon exemplar for training. You can produce cartoon exemplars with the style-finetuned Stable-Diffusion (SD) models, which can be downloaded from modelscope or huggingface hubs.

The effects of some style-finetune SD models are as follows:

design watercolor illustration clipart flat
  • Generate stylized data, style choice [option: clipart, design, illustration, watercolor, flat]
python generate_data.py --style clipart
  • preprocess

extract aligned faces from raw style images:

python extract_align_faces.py --src_dir 'data/raw_style_data'
  • train content calibration network

install environment required by stylegan2-pytorch

cd source/stylegan2
python prepare_data.py '../../data/face_cartoon' --size 256 --out '../../data/stylegan2/traindata'
python train_condition.py --name 'ffhq_style_s256' --path '../../data/stylegan2/traindata' --config config/conf_server_train_condition_shell.json

after training, generated content calibrated samples via:

python style_blend.py --name 'ffhq_style_s256'
python generate_blendmodel.py --name 'ffhq_style_s256' --save_dir '../../data/face_cartoon/syn_style_faces'
  • geometry calibration

run geometry calibration for both photo and cartoon:

cd source
python image_flip_agument_parallel.py --data_dir '../data/face_cartoon'
python image_scale_agument_parallel_flat.py --data_dir '../data/face_cartoon'
python image_rotation_agument_parallel_flat.py --data_dir '../data/face_cartoon'
  • train texture translator

The dataset structure is recommended as:

+—data
|   +—face_photo
|   +—face_cartoon

resume training from pretrained model in similar style,

style can be chosen from 'anime, 3d, handdrawn, sketch, artstyle, sd-design, sd-illustration'

python train_localtoon.py --data_dir PATH_TO_YOU_DATA --work_dir PATH_SAVE --style anime

Acknowledgments

Face detector and aligner are adapted from Peppa_Pig_Face_Engine and InsightFace.

Citation

If you find this code useful for your research, please use the following BibTeX entry.

@inproceedings{men2022dct,
  title={DCT-Net: Domain-Calibrated Translation for Portrait Stylization},
  author={Men, Yifang and Yao, Yuan and Cui, Miaomiao and Lian, Zhouhui and Xie, Xuansong},
  journal={ACM Transactions on Graphics (TOG)},
  volume={41},
  number={4},
  pages={1--9},
  year={2022},
  publisher={ACM New York, NY, USA}
}

dct-net's People

Contributors

ak391 avatar menyifang 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

dct-net's Issues

error after python run_sdk.py

2022-08-11 12:29:20,507 - modelscope - WARNING - ('PIPELINES', 'image-portrait-stylization', 'unet-person-image-cartoon') not found in ast index file
Traceback (most recent call last):
File "run_sdk.py", line 5, in
img_cartoon = pipeline(Tasks.image_portrait_stylization, 'damo/cv_unet_person-image-cartoon_compound-models')
File "C:\Users\George\anaconda3\envs\dctnet\lib\site-packages\modelscope\pipelines\builder.py", line 250, in pipeline
return build_pipeline(cfg, task_name=task)
File "C:\Users\George\anaconda3\envs\dctnet\lib\site-packages\modelscope\pipelines\builder.py", line 162, in build_pipeline
return build_from_cfg(
File "C:\Users\George\anaconda3\envs\dctnet\lib\site-packages\modelscope\utils\registry.py", line 197, in build_from_cfg
raise KeyError(f'{obj_type} is not in the {registry.name}'
KeyError: 'unet-person-image-cartoon is not in the pipelines registry group image-portrait-stylization'

multi-style/download error

root@0c1b63d9300d:~/project/mydev/DCT-Net# python multi-style/download.py --style 3d
download 3d model
2023-02-09 09:06:57,604 - modelscope - INFO - Model revision not specified, use the latest revision: v1.0.0
2023-02-09 09:06:57,884 - modelscope - INFO - downloading http://www.modelscope.cn/api/v1/models/damo/cv_unet_person-image-cartoon-3d_compound-models/repo?Revision=v1.0.0&FilePath=alpha.jpg to /root/project/mydev/DCT-Net/temp/tmpxiw9k_fi/tmpv1togmif
Downloading: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.52k/2.52k [00:00<00:00, 6.67MB/s]
2023-02-09 09:06:57,936 - modelscope - INFO - storing http://www.modelscope.cn/api/v1/models/damo/cv_unet_person-image-cartoon-3d_compound-models/repo?Revision=v1.0.0&FilePath=alpha.jpg in cache at ./temp/tmpxiw9k_fi
2023-02-09 09:06:57,936 - modelscope - ERROR - File ./temp/tmpxiw9k_fi/alpha.jpg integrity check failed, the download may be incomplete, please try again.
Traceback (most recent call last):
File "multi-style/download.py", line 35, in
process(args)
File "multi-style/download.py", line 13, in process
model_dir = snapshot_download('damo/cv_unet_person-image-cartoon-3d_compound-models', cache_dir='.')
File "/opt/conda/lib/python3.7/site-packages/modelscope/hub/snapshot_download.py", line 146, in snapshot_download
file_integrity_validation(temp_file, model_file[FILE_HASH])
File "/opt/conda/lib/python3.7/site-packages/modelscope/hub/utils/utils.py", line 94, in file_integrity_validation
raise FileIntegrityError(msg)
modelscope.hub.errors.FileIntegrityError: File ./temp/tmpxiw9k_fi/alpha.jpg integrity check failed, the download may be incomplete, please try again.

how about to set loss perception

Hi , I try to try to implement the function of face stylization, It can not get a good effect about cartoon nose, paper has no refered to use nose local components. However section 4.5.2 and Fig 11 indicat it is important to set face perception loss.

tensorflow.python.framework.errors_impl.NotFoundError: damo/cv_unet_person-image-cartoon-3d_compound-models/cartoon_anime_h.pb; No such file or directory

when running python multi-style/run.py --style 3d I get

Traceback (most recent call last):
  File "multi-style/run.py", line 46, in <module>
    process(args)
  File "multi-style/run.py", line 17, in process
    algo = Cartoonizer(dataroot='damo/cv_unet_person-image-cartoon-3d_compound-models')
  File "./source/cartoonize.py", line 19, in __init__
    os.path.join(dataroot, 'cartoon_anime_h.pb'), 'model_head')
  File "./source/cartoonize.py", line 38, in load_sess
    graph_def.ParseFromString(f.read())
  File "/root/miniconda3/envs/python-app/lib/python3.7/site-packages/tensorflow_core/python/lib/io/file_io.py", line 122, in read
    self._preread_check()
  File "/root/miniconda3/envs/python-app/lib/python3.7/site-packages/tensorflow_core/python/lib/io/file_io.py", line 84, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512)
tensorflow.python.framework.errors_impl.NotFoundError: damo/cv_unet_person-image-cartoon-3d_compound-models/cartoon_anime_h.pb; No such file or directory

Error on x64_86 Mac

(dctnet) sam@MacBook-Pro DCT-Net % python run_sdk.py
2022-08-11 13:36:00,612 - modelscope - INFO - PyTorch version 1.12.1 Found.
2022-08-11 13:36:00,615 - modelscope - INFO - TensorFlow version 2.9.1 Found.
2022-08-11 13:36:00,615 - modelscope - INFO - Loading ast index from /Users/sam/.cache/modelscope/ast_indexer
2022-08-11 13:36:00,615 - modelscope - INFO - No valid ast index found from /Users/sam/.cache/modelscope/ast_indexer, rebuilding ast index!
2022-08-11 13:36:00,618 - modelscope - INFO - AST-Scaning the path "/Users/sam/opt/anaconda3/envs/dctnet/lib/python3.8/site-packages/modelscope" with the following sub folders ['models', 'metrics', 'pipelines', 'preprocessors', 'task_datasets', 'trainers']
2022-08-11 13:36:06,550 - modelscope - INFO - Scaning done! A number of 177 files indexed! Time consumed 5.93245792388916s
2022-08-11 13:36:06,556 - modelscope - INFO - Loading done! Current index file version is 0.3.4, with md5 25b9fd3171728254b9475e3039bc0155
zsh: illegal hardware instruction  python run_sdk.py
(dctnet) sam@MacBook-Pro DCT-Net % 

installing modelscope by dockerfile, dont work

if you installing modelscope use this image registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-cuda11.3.0-py37-torch1.11.0-tf1.15.5-1.3.0, 'CartoonTranslationTrainer' and other related files are missing, please be careful to install modelscope with the latest 'master' branch.

face flicker

When the character is not moving, the picture will flicker

Facial perception constraint

In my understanding you use a well-trained expression regressor (R_exp) to conduct this constraint. So I'd like to know whether the regressor (R_exp) is trained differently according to the style, like for anime style you may train R_exp on anime images with anime face landmark detectors, but for 3d cartoon style you may train R_exp on 3d cartoon images with 3d cartoon face landmark detectors? Is that so? Wish your reply.

No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'

这个问题困扰了很久, cuda环境没有问题, torch版本是1.13.1+cu116
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
Traceback (most recent call last):
File "generate_blendmodel.py", line 6, in
from model import Generator
File "/root/ljf/DCT-Net-main/source/stylegan2/model.py", line 12, in
from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
File "/root/ljf/DCT-Net-main/source/stylegan2/op/init.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "/root/ljf/DCT-Net-main/source/stylegan2/op/fused_act.py", line 15, in
os.path.join(module_path, "fused_bias_act_kernel.cu"),
File "/root/xiaofei/miniconda3/envs/dctnet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1296, in load
keep_intermediates=keep_intermediates)
File "/root/xiaofei/miniconda3/envs/dctnet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1518, in _jit_compile
is_standalone=is_standalone)
File "/root/xiaofei/miniconda3/envs/dctnet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1619, in _write_ninja_file_and_build_library
is_standalone=is_standalone)
File "/root/xiaofei/miniconda3/envs/dctnet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 2014, in _write_ninja_file_to_build_library
cuda_flags = common_cflags + COMMON_NVCC_FLAGS + _get_cuda_arch_flags()
File "/root/xiaofei/miniconda3/envs/dctnet/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1780, in _get_cuda_arch_flags
arch_list[-1] += '+PTX'
IndexError: list index out of range

result is not good

Hi, I use anime style model to test celeb dataset. It has some bad cases and artifacts. The pose seems not large. How to solve this? Thanks! @menyifang
image
image

Question about Training Code

Hello,
Thank you for such amazing work on portrait stylisation. Can you please let us know when it will be released ?
Thanks again

Invalid SSL certificate of "modelscope"

When trying to install "modelscope" with "pip install "modelscope[cv]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html" I get these error messages:
"WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)'))': /releases/repo.html"

Training code releasing plan

Hello!
Thanks for sharing nice work!
I would like to know whether training code and the dataset will be released or not..
It would be very helpful to study the model :)

Best regards,
B.

question about CCN

i have made a styleganv2 and trained it on ffhq for 80w iters with bs == 32 , i think the pretrain model is enought. And i am trying to build the ccn u mentioned in the paper. I found that ur paper doesn't talk about the weight of gan loss and id loss, can u show the part of ccn in details thank u

check fail

run download.py

2023-05-24 18:51:54,682 - modelscope - INFO - PyTorch version 1.13.0+cu116 Found.
2023-05-24 18:51:54,683 - modelscope - INFO - Loading ast index from /home/bill/.cache/modelscope/ast_indexer
2023-05-24 18:51:54,683 - modelscope - INFO - No valid ast index found from /home/bill/.cache/modelscope/ast_indexer, generating ast index from prebuilt!
2023-05-24 18:51:54,711 - modelscope - INFO - Loading done! Current index file version is 1.6.0, with md5 09291f9b1c05d846d582e5692ab7db00 and a total number of 848 components indexed
2023-05-24 18:51:55,033 - modelscope - INFO - Model revision not specified, use the latest revision: v1.0.3
Downloading: 100%|██████████| 2.55k/2.55k [00:00<00:00, 29.0MB/s]
2023-05-24 18:51:57,710 - modelscope - ERROR - File ./temp/tmp_t6mf2dq/alpha.jpg integrity check failed, the download may be incomplete, please try again.
Traceback (most recent call last):
  File "/home/bill/E/dl-base/AI_VirtualPerson_Related/DCT-Net/download.py", line 3, in <module>
    model_dir = snapshot_download('damo/cv_unet_person-image-cartoon_compound-models', cache_dir='.')
  File "/home/bill/D/Anaconda_2023_3/envs/mypipeline/lib/python3.9/site-packages/modelscope/hub/snapshot_download.py", line 146, in snapshot_download
    file_integrity_validation(temp_file, model_file[FILE_HASH])
  File "/home/bill/D/Anaconda_2023_3/envs/mypipeline/lib/python3.9/site-packages/modelscope/hub/utils/utils.py", line 94, in file_integrity_validation
    raise FileIntegrityError(msg)
modelscope.hub.errors.FileIntegrityError: File ./temp/tmp_t6mf2dq/alpha.jpg integrity check failed, the download may be incomplete, please try again.

Design style result not good enough on 10,000 step.

Hi, I have trained the design style by the following steps with default config:

  1. Run python generate_data.py --style design
  2. Run python extract_align_faces.py and pick 200 style images
  3. Train content calibration network
  4. Generated content calibrated samples
  5. Run geometry calibration for both photo and cartoon
  6. Run python train_localtoon.py with total 19962 source images & 79832 style images

The result of 10,000 step is not as good as official pre-train:
    9999_face_result

Did I do any step wrong? Thank you very much!

Code in project is not consistent with content in this paper

In this paper, author said "A common practice to achieve the aforementioned goal is to process face and background independently. As described in Figure 6, they firstly extract aligned faces from the input image and stylize all the faces one-by-one. Then, the background image is rendered with some specialized algorithms and merged with stylized faces to obtain the final result. Instead of using such complex pipeline, we found that our texture translation network can directly render stylized results from full images in one-pass evaluation." However, code in project (https://github.com/menyifang/DCT-Net/blob/main/source/cartoonize.py) shows that, two different models (one for background and one for face) are needed in the inference phase. Meanwhile, when dealing with multi faces in one image, each face need to be aligned, processed and projected to origin position. Each cartoonized face need to be pasted on cartoonized backgound image. In summary, implementation details in this project are totally different with the statement in paper.

Did I misunderstand the code? Or you just released the wrong code?

关于训练步骤

1 准备好 face_photo(10000) 和 face_cartoon (100300)
2 python generate_data.py --style clipart 这一步是做什么的,第1步不是已经准备好数据了吗?
3 python extract_align_faces.py --src_dir 'data/raw_style_data' :这一步raw_style_data是指第1步中的 face_cartoon?还是face_photo?

NotImplementedError: Cannot convert a symbolic Tensor (strided_slice:0) to a numpy array.

Traceback (most recent call last):
File "train_localtoon.py", line 36, in
main(args)
File "train_localtoon.py", line 25, in main
max_steps=max_steps)
File "/opt/conda/lib/python3.7/site-packages/modelscope/trainers/cv/cartoon_translation_trainer.py", line 99, in init
self.input_superpixel)
File "/opt/conda/lib/python3.7/site-packages/modelscope/models/cv/cartoon/model_tf.py", line 39, in call
output_cartoon = guided_filter(input_photo, output, r=1)
File "/opt/conda/lib/python3.7/site-packages/modelscope/models/cv/cartoon/loss.py", line 209, in guided_filter
tf.ones((1, x_shape[1], x_shape[2], 1), dtype=x.dtype), r)
File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 2560, in ones
output = _constant_if_small(one, shape, dtype, name)
File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/ops/array_ops.py", line 2295, in _constant_if_small
if np.prod(shape) < 1000:
File "<array_function internals>", line 6, in prod
File "/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 3052, in prod
keepdims=keepdims, initial=initial, where=where)
File "/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
File "/opt/conda/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py", line 736, in array
" array.".format(self.name))
NotImplementedError: Cannot convert a symbolic Tensor (strided_slice:0) to a numpy array.

question

In addition to anime, how to convert other cartoon images

不知道这个源码在那

/workspaces/VideoTransfer-DCT-Net/source/pycache
生成的这个pyc文件的源码在那,有大佬能解答一下吗?新手,谢谢

训练水彩风格

你好, 如果我想训练水彩风格的dctnet模型, 对于train_localtoon.py中style参数应该如何调整.

请问加载多个pb的冲突如何解决?

这个效果相当惊艳,感谢作者开源,我想利用它训练自己的模型并实现随时切换,尝试修改tf加载pb时一直没有成功,请问下同时加载多个pb时应该如何处理冲突问题?

Questions about the separation of the head model and the background model

Thank you for your impressive work.
Also thank you for sharing the model and code.
We believe this work is one of the most important in the field of style transfer this year.

I studied the code you posted in detail. The separation of the head transition model and the background transition model is very confusing to me. In the paper, the details we get are that we only need a Texture translation network to uniformly transfer the style of the whole image.
It is this feature that impresses me!

Looking forward to your reply.

Best,

CUDA support doesnot work

Hi i have noticied that CUDA is not working? Does DCT-Net suports CUDA calculations?

I had to install first
conda install cudatoolkit=10.1
conda install cudnn

It uses CUDA but with error
2022-12-04 09:31:23.527110: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): NVIDIA RTX A4500, Compute Capability 8.6
2022-12-04 09:31:23.527239: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-12-04 09:31:23.527364: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:0a:00.0 name: NVIDIA RTX A4500 computeCapability: 8.6
coreClock: 1.65GHz coreCount: 56 deviceMemorySize: 19.70GiB deviceMemoryBandwidth: 596.12GiB/s
2022-12-04 09:31:23.527408: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2022-12-04 09:31:23.528422: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2022-12-04 09:31:23.529403: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2022-12-04 09:31:23.529550: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2022-12-04 09:31:23.530466: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2022-12-04 09:31:23.530985: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2022-12-04 09:31:23.532948: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7
2022-12-04 09:31:23.533015: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-12-04 09:31:23.533156: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-12-04 09:31:23.533241: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2022-12-04 09:31:23.533267: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2022-12-04 09:31:23.552689: E tensorflow/core/common_runtime/session.cc:91] Failed to create session: Internal: CUDA runtime implicit initialization on GPU:0 failed. Status: device kernel image is invalid
2022-12-04 09:31:23.552708: E tensorflow/c/c_api.cc:2184] Internal: CUDA runtime implicit initialization on GPU:0 failed. Status: device kernel image is invalid
Traceback (most recent call last):
File "/home/alexandr/miniforge3/envs/dctnet/lib/python3.8/site-packages/modelscope/utils/registry.py", line 211, in build_from_cfg
return obj_cls(**args)
File "/home/alexandr/miniforge3/envs/dctnet/lib/python3.8/site-packages/modelscope/pipelines/cv/image_cartoon_pipeline.py", line 42, in init
self.facer = FaceAna(self.model)
File "/home/alexandr/miniforge3/envs/dctnet/lib/python3.8/site-packages/modelscope/models/cv/cartoon/facelib/facer.py", line 20, in init
self.face_detector = FaceDetector(model_dir)
File "/home/alexandr/miniforge3/envs/dctnet/lib/python3.8/site-packages/modelscope/models/cv/cartoon/facelib/face_detector.py", line 26, in init
self._graph, self._sess = self.init_model(self.model_path)
File "/home/alexandr/miniforge3/envs/dctnet/lib/python3.8/site-packages/modelscope/models/cv/cartoon/facelib/face_detector.py", line 113, in init_model
model = init_pb(pb_path)
File "/home/alexandr/miniforge3/envs/dctnet/lib/python3.8/site-packages/modelscope/models/cv/cartoon/facelib/face_detector.py", line 105, in init_pb
sess = tf.Session(config=config)
File "/home/alexandr/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 1586, in init
super(Session, self).init(target, graph, config=config)
File "/home/alexandr/.local/lib/python3.8/site-packages/tensorflow/python/client/session.py", line 701, in init
self._session = tf_session.TF_NewSessionRef(self._graph._c_graph, opts)
tensorflow.python.framework.errors_impl.InternalError: CUDA runtime implicit initialization on GPU:0 failed. Status: device kernel image is invalid

During handling of the above exception, another exception occurred:

executable error

hello.
What should I do?

  • step 1
    (dctnet) PS C:\Users\simgok\anaconda3\envs\dctnet\multi-style> pyinstaller run_sdk.spec

  • step 2
    C:\Users\simgok\anaconda3\envs\dctnet\multi-style\dist\run_sdk>run_sdk.exe

  • error
    2023-03-02 18:47:39,002 - modelscope - INFO - PyTorch version 1.13.1 Found.
    2023-03-02 18:47:39,007 - modelscope - INFO - Loading ast index from C:\Users\simgok.cache\modelscope\ast_indexer
    2023-03-02 18:47:39,008 - modelscope - INFO - Loading done! Current index file version is 1.3.0, with md5 d41d8cd98f00b204e9800998ecf8427e and a total number of 0 components indexed
    Traceback (most recent call last):
    File "run_sdk.py", line 3, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "modelscope\pipelines_init
    .py", line 6, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in _load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "modelscope\pipelines\base.py", line 14, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "modelscope\msdatasets_init
    .py", line 3, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in _load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "modelscope\msdatasets\ms_dataset.py", line 9, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "datasets_init
    .py", line 52, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in _load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "datasets\inspect.py", line 30, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in _load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "datasets\load.py", line 57, in
    File "", line 983, in _find_and_load
    File "", line 967, in _find_and_load_unlocked
    File "", line 677, in load_unlocked
    File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
    File "datasets\packaged_modules_init
    .py", line 31, in
    File "inspect.py", line 973, in getsource
    File "inspect.py", line 955, in getsourcelines
    File "inspect.py", line 786, in findsource
    OSError: could not get source code
    [4836] Failed to execute script 'run_sdk' due to unhandled exception!

About 3d cartoon data

The 3D cartoon result is very good!!! What kind of data is used for the 3dcartoon data during training, and the approximate amount of data.

modelscope error while downloading

Looking in links: https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /releases/repo.html
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /releases/repo.html
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /releases/repo.html
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /releases/repo.html
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /releases/repo.html
Could not fetch URL https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='modelscope.oss-cn-beijing.aliyuncs.com', port=443): Max retries exceeded with url: /releases/repo.html (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))) - skipping
ERROR: Could not find a version that satisfies the requirement modelscope[cv] (from versions: none)
ERROR: No matching distribution found for modelscope[cv]

The download model name is different from the load name in the source code

run.py only work on anime style, but failed on others. Bellow is my log info.(run2.py is copy from multi-style run.py and renamed)

D:\Documents\Code\Cartoon\DCT-Net-main\run2.py 
2023-03-09 15:20:21.576244: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2023-03-09 15:20:23,930 - modelscope - INFO - PyTorch version 1.13.1 Found.
2023-03-09 15:20:23,932 - modelscope - INFO - TensorFlow version 2.1.0 Found.
2023-03-09 15:20:23,932 - modelscope - INFO - Loading ast index from C:\Users\MJJ\.cache\modelscope\ast_indexer
2023-03-09 15:20:23,978 - modelscope - INFO - Loading done! Current index file version is 1.3.2, with md5 fc8b9444f94006776df1e23019c21d88 and a total number of 754 components indexed
2023-03-09 15:20:24.036495: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2023-03-09 15:20:24.038627: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2023-03-09 15:20:24.046150: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: NVIDIA GeForce GTX 1070 Ti computeCapability: 6.1
coreClock: 1.683GHz coreCount: 19 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s
2023-03-09 15:20:24.046307: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2023-03-09 15:20:24.048652: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2023-03-09 15:20:24.051102: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2023-03-09 15:20:24.051798: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2023-03-09 15:20:24.054790: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2023-03-09 15:20:24.056258: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2023-03-09 15:20:24.062435: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2023-03-09 15:20:24.062554: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2023-03-09 15:20:24.423445: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-03-09 15:20:24.423538: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2023-03-09 15:20:24.423601: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2023-03-09 15:20:24.423795: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1638 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce GTX 1070 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
2023-03-09 15:20:25.589881: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: NVIDIA GeForce GTX 1070 Ti computeCapability: 6.1
coreClock: 1.683GHz coreCount: 19 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s
2023-03-09 15:20:25.590051: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2023-03-09 15:20:25.590128: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2023-03-09 15:20:25.590208: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2023-03-09 15:20:25.590289: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2023-03-09 15:20:25.590364: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2023-03-09 15:20:25.590440: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2023-03-09 15:20:25.590516: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2023-03-09 15:20:25.590604: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2023-03-09 15:20:25.590685: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-03-09 15:20:25.590762: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2023-03-09 15:20:25.591199: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2023-03-09 15:20:25.591295: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1638 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce GTX 1070 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
loading model from damo/cv_unet_person-image-cartoon-3d_compound-models\cartoon_anime_h.pb
2023-03-09 15:20:26.638834: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: NVIDIA GeForce GTX 1070 Ti computeCapability: 6.1
coreClock: 1.683GHz coreCount: 19 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 238.66GiB/s
2023-03-09 15:20:26.638996: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2023-03-09 15:20:26.639072: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2023-03-09 15:20:26.639146: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2023-03-09 15:20:26.639219: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2023-03-09 15:20:26.639292: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2023-03-09 15:20:26.639367: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2023-03-09 15:20:26.639442: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2023-03-09 15:20:26.639526: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2023-03-09 15:20:26.639607: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2023-03-09 15:20:26.639683: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102]      0 
2023-03-09 15:20:26.639731: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0:   N 
2023-03-09 15:20:26.639814: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1638 MB memory) -> physical GPU (device: 0, name: NVIDIA GeForce GTX 1070 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
WARNING:tensorflow:From D:\Documents\Code\Cartoon\DCT-Net-main\source\cartoonize.py:36: FastGFile.__init__ (from tensorflow.python.platform.gfile) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.gfile.GFile.

Process finished with exit code -1073741819 (0xC0000005)

'anime' style results in very pointed chin

Thanks for the amazing work. I have tried the 'anime' style model and all of the 'anime' people have very pointed chins, is there any way to modify the pointed level of the chin without changing the model?

Thanks in advance~

add model to Hugging Face

Hi thanks for merging PR for the web demo on Hugging Face #14, would you also be interested in adding the model to huggingface, you can see the guide for this here: https://huggingface.co/docs/hub/models-uploading

also we are having a event for siggraph this month, so they can be shared in the siggraph organization: https://huggingface.co/SIGGRAPH2022, which you can join by using this link: https://huggingface.co/organizations/SIGGRAPH2022/share/lKvMytVEyvqyWBIbfrcZTeBhNQLXklhIHG,

let me know if you have any questions, thanks

Training Clipart-Style tooth or teeth issues

Hi,
congrats on the great paper!

I want to try to port this nice work to a mobile.
But before getting started with performance I tried to reproduce the results.

As suggested I went with one of the SD Sytsles as it seemed easy to generate data.
I tried the clipart style.

Here is an example of a generated clipart image
image

they all look pretty good.
Afterwards I went on to genreate samples via stylegan2.
image

I realized that the generated cartoon samples of Stylegan are only 256x256 is that an issue ?

Anyway, next step is training the texture translator, starting with anime model as initial weights.

Iteration0 (basically anime style)
image

Iteration 1000
image

Iteration 10000
image

Iteration 30000
image

Iteration 100000
image
image

Here are the loss curves
image

From the images I saw so far, it really is catching the style nicely. But it has a major problem with teeth. Unfortanetly thats quiet an important facial part.

My question is:

  • Did I mess something up in the training procedure. E.g. I saw In your paper under Fig. 11 a similar effect which is countered by the facial perception loss. Is changing the weight of the facial perception loss a good idea to get better teeth (less content faithfull, but better looking)

  • Is the style just not usable with the framework and I should go for some other style instead ?

  • Or is it just an issue with SD generated data.

I am happy to test any different style to validate the training process, if you can point me to a dataset I should use and some intermediate results which are expected to be achieved.

Bonus Question - this is just loud thinking:

As my final goal is to get something really performant. I would like to switch out the Unet by a mobilenet v3. I am currently not sure if a mobilenet can pick up the unsupervised training signal or if it would be better train Unet first and use a teacher / student approach to transfer the training resuluts to a mobilenet in a supervised training fashion. Did you test out different architectures forthe texture translation block ?

Sorry for the many questions, but its such an interesting work I could ask 100 more (but I wont, promised 🤞 )

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.