diff --git a/.DS_Store b/.DS_Store
index 0c8f893..3649d19 100644
Binary files a/.DS_Store and b/.DS_Store differ
diff --git a/README.md b/README.md
index 049cc93..5c459fb 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,9 @@ Official implementation of DCT-Net for Full-body Portrait Stylization.
> In: SIGGRAPH 2022 (**TOG**)
> *[arXiv preprint](https://arxiv.org/abs/2207.02426)*
+
+[![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/SIGGRAPH2022/DCT-Net)
+
## Demo
![demo_vid](assets/demo.gif)
@@ -29,6 +32,7 @@ Official implementation of DCT-Net for Full-body Portrait Stylization.
## Web Demo
+- Integrated into [Colab notebook](https://colab.research.google.com/github/menyifang/DCT-Net/blob/main/notebooks/inference.ipynb). Try out the colab demo.
- Integrated into [Huggingface Spaces 🤗](https://huggingface.co/spaces) using [Gradio](https://github.com/gradio-app/gradio). Try out the Web Demo [![Hugging Face Spaces](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/SIGGRAPH2022/DCT-Net)
@@ -41,6 +45,8 @@ Official implementation of DCT-Net for Full-body Portrait Stylization.
## Quick Start
+
+
```bash
git clone https://github.com/menyifang/DCT-Net.git
diff --git a/notebooks/inference.ipynb b/notebooks/inference.ipynb
index 7210b5a..4f6444c 100644
--- a/notebooks/inference.ipynb
+++ b/notebooks/inference.ipynb
@@ -1,286 +1,295 @@
{
- "nbformat": 4,
- "nbformat_minor": 0,
- "metadata": {
- "colab": {
- "provenance": [],
- "collapsed_sections": []
- },
- "kernelspec": {
- "name": "python3",
- "display_name": "Python 3"
- },
- "language_info": {
- "name": "python"
- }
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "provenance": [],
+ "collapsed_sections": []
},
- "cells": [
- {
- "cell_type": "markdown",
- "source": [
- "## Step 1: Installation"
- ],
- "metadata": {
- "id": "zoNN1PYUOUgU"
- }
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "id": "7Tv2ZUgrGO6Z"
- },
- "outputs": [],
- "source": [
- "!pip install tensorflow\n",
- "!pip install \"modelscope[cv]\" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html"
- ]
- },
- {
- "cell_type": "markdown",
- "source": [
- "## Step 2: Transfer image"
- ],
- "metadata": {
- "id": "kTiXDn7_OTMy"
- }
- },
- {
- "cell_type": "code",
- "source": [
- "!wget 'https://invi-label.oss-cn-shanghai.aliyuncs.com/label/cartoon/image_cartoon.png'"
- ],
- "metadata": {
- "id": "lL2JQBL5Qqjn"
- },
- "execution_count": null,
- "outputs": []
- },
- {
- "cell_type": "code",
- "source": [
- "### portrait stylization with 'anime' style\n",
- "\n",
- "import cv2\n",
- "from modelscope.outputs import OutputKeys\n",
- "from modelscope.pipelines import pipeline\n",
- "from modelscope.utils.constant import Tasks\n",
- "\n",
- "img_cartoon = pipeline(Tasks.image_portrait_stylization, \n",
- " model='damo/cv_unet_person-image-cartoon_compound-models')\n",
- "img_path = 'image_cartoon.png'\n",
- "result = img_cartoon(img_path)\n",
- "cv2.imwrite('result_anime.png', result[OutputKeys.OUTPUT_IMG])\n",
- "print('finished!')\n"
- ],
- "metadata": {
- "id": "IiuxwjdcJkAf"
- },
- "execution_count": null,
- "outputs": []
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "source": [
+ "x[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/menyifang/DCT-Net/blob/main/notebooks/inference.ipynb)"
+ ],
+ "metadata": {
+ "id": "D2MFmZtpVEp_"
+ }
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Step 1: Installation"
+ ],
+ "metadata": {
+ "id": "zoNN1PYUOUgU"
+ }
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "7Tv2ZUgrGO6Z"
+ },
+ "outputs": [],
+ "source": [
+ "!pip install tensorflow\n",
+ "!pip install \"modelscope[cv]\" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Step 2: Transfer image"
+ ],
+ "metadata": {
+ "id": "kTiXDn7_OTMy"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "!wget 'https://invi-label.oss-cn-shanghai.aliyuncs.com/label/cartoon/image_cartoon.png'"
+ ],
+ "metadata": {
+ "id": "lL2JQBL5Qqjn"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "### portrait stylization with 'anime' style\n",
+ "\n",
+ "import cv2\n",
+ "from modelscope.outputs import OutputKeys\n",
+ "from modelscope.pipelines import pipeline\n",
+ "from modelscope.utils.constant import Tasks\n",
+ "\n",
+ "img_cartoon = pipeline(Tasks.image_portrait_stylization, \n",
+ " model='damo/cv_unet_person-image-cartoon_compound-models')\n",
+ "img_path = 'image_cartoon.png'\n",
+ "result = img_cartoon(img_path)\n",
+ "cv2.imwrite('result_anime.png', result[OutputKeys.OUTPUT_IMG])\n",
+ "print('finished!')\n"
+ ],
+ "metadata": {
+ "id": "IiuxwjdcJkAf"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "### portrait stylization with '3d' style\n",
+ "\n",
+ "import cv2\n",
+ "from modelscope.outputs import OutputKeys\n",
+ "from modelscope.pipelines import pipeline\n",
+ "from modelscope.utils.constant import Tasks\n",
+ "\n",
+ "img_cartoon = pipeline(Tasks.image_portrait_stylization, \n",
+ " model='damo/cv_unet_person-image-cartoon-3d_compound-models')\n",
+ "img_path = 'image_cartoon.png'\n",
+ "result = img_cartoon(img_path)\n",
+ "cv2.imwrite('result_3d.png', result[OutputKeys.OUTPUT_IMG])\n",
+ "print('finished!')"
+ ],
+ "metadata": {
+ "id": "FvESA08aPC5a"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "### portrait stylization with 'handdrawn' style\n",
+ "\n",
+ "import cv2\n",
+ "from modelscope.outputs import OutputKeys\n",
+ "from modelscope.pipelines import pipeline\n",
+ "from modelscope.utils.constant import Tasks\n",
+ "\n",
+ "img_cartoon = pipeline(Tasks.image_portrait_stylization, \n",
+ " model='damo/cv_unet_person-image-cartoon-handdrawn_compound-models')\n",
+ "img_path = 'image_cartoon.png'\n",
+ "result = img_cartoon(img_path)\n",
+ "cv2.imwrite('result_handdrawn.png', result[OutputKeys.OUTPUT_IMG])\n",
+ "print('finished!')\n"
+ ],
+ "metadata": {
+ "id": "MZdiNAuTPm-t"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "### portrait stylization with 'sketch' style\n",
+ "\n",
+ "import cv2\n",
+ "from modelscope.outputs import OutputKeys\n",
+ "from modelscope.pipelines import pipeline\n",
+ "from modelscope.utils.constant import Tasks\n",
+ "\n",
+ "img_cartoon = pipeline(Tasks.image_portrait_stylization, \n",
+ " model='damo/cv_unet_person-image-cartoon-sketch_compound-models')\n",
+ "img_path = 'image_cartoon.png'\n",
+ "result = img_cartoon(img_path)\n",
+ "cv2.imwrite('result_sketch.png', result[OutputKeys.OUTPUT_IMG])\n",
+ "print('finished!')"
+ ],
+ "metadata": {
+ "id": "1Dut6IQ4PnMA"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "### portrait stylization with 'artstyle' style\n",
+ "\n",
+ "import cv2\n",
+ "from modelscope.outputs import OutputKeys\n",
+ "from modelscope.pipelines import pipeline\n",
+ "from modelscope.utils.constant import Tasks\n",
+ "\n",
+ "img_cartoon = pipeline(Tasks.image_portrait_stylization, \n",
+ " model='damo/cv_unet_person-image-cartoon-artstyle_compound-models')\n",
+ "img_path = 'image_cartoon.png'\n",
+ "result = img_cartoon(img_path)\n",
+ "cv2.imwrite('result_artstyle.png', result[OutputKeys.OUTPUT_IMG])\n",
+ "print('finished!')\n"
+ ],
+ "metadata": {
+ "id": "gNchD8nGPnZE"
+ },
+ "execution_count": null,
+ "outputs": []
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## Step 3: Visualize results"
+ ],
+ "metadata": {
+ "id": "fShi4lT-ODdE"
+ }
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "### Visualize source image and stylized result\n",
+ "from matplotlib import pyplot as plt\n",
+ "def vis_img(path):\n",
+ " img = cv2.imread(path,-1)\n",
+ " plt.imshow(img[..., ::-1])\n",
+ " plt.axis(\"off\")\n",
+ " plt.show()\n",
+ "\n",
+ "vis_img('image_cartoon.png')\n",
+ "vis_img('result_anime.png')\n",
+ "vis_img('result_3d.png')\n",
+ "vis_img('result_handdrawn.png')\n",
+ "vis_img('result_sketch.png')\n",
+ "vis_img('result_artstyle.png')"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 1000
},
+ "id": "k7Llm0SWMLKr",
+ "outputId": "20b665ce-653e-48a9-c489-d66e93e1907f"
+ },
+ "execution_count": 21,
+ "outputs": [
{
- "cell_type": "code",
- "source": [
- "### portrait stylization with '3d' style\n",
- "\n",
- "import cv2\n",
- "from modelscope.outputs import OutputKeys\n",
- "from modelscope.pipelines import pipeline\n",
- "from modelscope.utils.constant import Tasks\n",
- "\n",
- "img_cartoon = pipeline(Tasks.image_portrait_stylization, \n",
- " model='damo/cv_unet_person-image-cartoon-3d_compound-models')\n",
- "img_path = 'image_cartoon.png'\n",
- "result = img_cartoon(img_path)\n",
- "cv2.imwrite('result_3d.png', result[OutputKeys.OUTPUT_IMG])\n",
- "print('finished!')"
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "