Skip to content

Commit

Permalink
Merge pull request #51 from miu200521358/develop
Browse files Browse the repository at this point in the history
Text2Motion_v1.01.03
  • Loading branch information
miu200521358 authored Apr 30, 2023
2 parents d856c4d + 05d51ff commit e5b8f6f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 60 deletions.
76 changes: 43 additions & 33 deletions Text2Motion1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Text2Motion_v1.01.02.ipynb",
"name": "Text2Motion_v1.01.03.ipynb",
"provenance": [],
"toc_visible": true
},
Expand Down Expand Up @@ -621,50 +621,47 @@
"\n",
"# ----------------------------\n",
"\n",
"# https://www.usagi1975.com/2019152355/\n",
"! apt-key adv --keyserver keyserver.ubuntu.com --recv aa9795093fe2f255acb3500d85304cfd1408787d\n",
"! echo \"deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic main \" > /etc/apt/sources.list.d/python.list\n",
"! echo \"deb-src http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic main\" >> /etc/apt/sources.list.d/python.list\n",
"! apt update\n",
"\n",
"# Python3.9にアップデート\n",
"!sudo apt-get -y update\n",
"!sudo apt-get -y install python3.9\n",
"!sudo apt-get -y install python3.9-dev\n",
"!sudo apt-get -y install python3-pip\n",
"!sudo apt-get -y install python3.9-distutils\n",
"!python3.9 -m pip install --upgrade setuptools\n",
"!python3.9 -m pip install --upgrade pip\n",
"!python3.9 -m pip install --upgrade distlib\n",
"\n",
"! sudo apt install libosmesa6-dev\n",
"! sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev gcc libyaml-dev\n",
"\n",
"import shutil\n",
"\n",
"if os.path.exists('./mmd-text-to-motion'):\n",
" shutil.rmtree('./mmd-text-to-motion')\n",
"\n",
"# Text2Motion v1 バージョンタグ\n",
"version_tag = \"v1.00.01\"\n",
"version_tag = \"v1.00.02\"\n",
"\n",
"! git clone --recursive --depth 1 -b \"$version_tag\" \"https://github.com/miu200521358/mmd-text-to-motion.git\"\n",
"\n",
"! python3.9 -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113\n",
"! python3.9 -m pip install --upgrade -r \"./mmd-text-to-motion/requirements.txt\"\n",
"! python -m spacy download en_core_web_sm\n",
"! BEZIER_NO_EXTENSION=true BEZIER_INSTALL_PREFIX=true python -m pip install bezier --no-binary=bezier\n",
"! pip install --upgrade -r \"./mmd-text-to-motion/requirements.txt\"\n",
"\n",
"! pip install moviepy==2.0.0.dev2\n",
"! pip install imageio-ffmpeg\n",
"! pip install google-cloud-secret-manager\n",
"! pip install deepl\n",
"# ----------------------------\n",
"\n",
"# GCP認証\n",
"from google.colab import auth\n",
"auth.authenticate_user()\n",
"\n",
"from google.cloud import secretmanager\n",
"\n",
"# 3.8系で使う\n",
"! python3.8 -m pip install moviepy==2.0.0.dev2\n",
"! python3.8 -m pip install imageio-ffmpeg\n",
"def access_secret(project_id, secret_name, version='latest'):\n",
" client = secretmanager.SecretManagerServiceClient()\n",
" name = client.secret_version_path(project_id, secret_name, version)\n",
" response = client.access_secret_version(request={\"name\":name})\n",
" payload = response.payload.data.decode(\"UTF-8\")\n",
" return payload\n",
"\n",
"# ----------------------------\n",
"\n",
"# セル終了\n",
"finish_cell(ckey)"
],
"metadata": {
"cellView": "form",
"id": "Wm_DfN5bhaCl"
"id": "Wm_DfN5bhaCl",
"cellView": "form"
},
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -794,14 +791,27 @@
" print(\"■■■■■■■■■■■■■■■\")\n",
" raise IpyExit\n",
"\n",
"# 日本語版は翻訳 --------\n",
"\n",
"PROJECT_ID = \"platinum-tube-316223\"\n",
"SECRET_NAME = \"DEEPL_API_KEY\"\n",
"deepl_api_key = access_secret(PROJECT_ID, SECRET_NAME)\n",
"\n",
"import deepl\n",
"\n",
"translator = deepl.Translator(deepl_api_key)\n",
"trans_text = translator.translate_text(p_prompt, source_lang=\"JA\", target_lang=\"EN-US\")\n",
"translated_prompt = trans_text.text\n",
"\n",
"# --------\n",
"\n",
"import datetime\n",
"process_dir_name = f\"{datetime.datetime.now():%Y%m%d_%H%M%S}\"\n",
"process_dir_path = f'/content/output/{process_dir_name}'\n",
"os.makedirs(process_dir_path, exist_ok=True)\n",
"\n",
"! cd /content/mmd-text-to-motion/src && python3.9 executor.py --seed $p_seed --seconds $p_seconds --num_repetitions $p_num_repetitions --text \"$p_prompt\" --parent-dir \"$process_dir_path\" --process text2move,mix,motion --verbose 20 --log-mode 0 --lang ja\n",
"! export PYTHONIOENCODING=utf-8 \n",
"! cd /content/mmd-text-to-motion/src && python executor.py --seed $p_seed --seconds $p_seconds --num_repetitions $p_num_repetitions --text \"$p_prompt\" --translated_text \"$translated_prompt\" --parent-dir \"$process_dir_path\" --process text2move,mix,motion --verbose 20 --log-mode 0 --lang ja\n",
"\n",
"import os\n",
"if os.path.exists(\"/content/mmd-text-to-motion/log/quit.log\"):\n",
Expand Down Expand Up @@ -842,8 +852,8 @@
"finish_cell(ckey)"
],
"metadata": {
"cellView": "form",
"id": "625x35Vaky9I"
"id": "625x35Vaky9I",
"cellView": "form"
},
"execution_count": null,
"outputs": []
Expand Down Expand Up @@ -893,8 +903,8 @@
"clip.ipython_display(width=(400 * len(clips)))"
],
"metadata": {
"cellView": "form",
"id": "XltsUFT9cBZh"
"id": "XltsUFT9cBZh",
"cellView": "form"
},
"execution_count": null,
"outputs": []
Expand Down
52 changes: 25 additions & 27 deletions Text2Motion1_en.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Text2Motion_v1.01.02_en.ipynb",
"name": "Text2Motion_v1.01.03_en.ipynb",
"provenance": [],
"toc_visible": true
},
Expand Down Expand Up @@ -618,41 +618,38 @@
"\n",
"# ----------------------------\n",
"\n",
"# https://www.usagi1975.com/2019152355/\n",
"! apt-key adv --keyserver keyserver.ubuntu.com --recv aa9795093fe2f255acb3500d85304cfd1408787d\n",
"! echo \"deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic main \" > /etc/apt/sources.list.d/python.list\n",
"! echo \"deb-src http://ppa.launchpad.net/deadsnakes/ppa/ubuntu bionic main\" >> /etc/apt/sources.list.d/python.list\n",
"! apt update\n",
"\n",
"# Python3.9にアップデート\n",
"!sudo apt-get -y update\n",
"!sudo apt-get -y install python3.9\n",
"!sudo apt-get -y install python3.9-dev\n",
"!sudo apt-get -y install python3-pip\n",
"!sudo apt-get -y install python3.9-distutils\n",
"!python3.9 -m pip install --upgrade setuptools\n",
"!python3.9 -m pip install --upgrade pip\n",
"!python3.9 -m pip install --upgrade distlib\n",
"\n",
"! sudo apt install libosmesa6-dev\n",
"! sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev gcc libyaml-dev\n",
"\n",
"import shutil\n",
"\n",
"if os.path.exists('./mmd-text-to-motion'):\n",
" shutil.rmtree('./mmd-text-to-motion')\n",
"\n",
"# Text2Motion v1 バージョンタグ\n",
"version_tag = \"v1.00.01\"\n",
"version_tag = \"v1.00.02\"\n",
"\n",
"! git clone --recursive --depth 1 -b \"$version_tag\" \"https://github.com/miu200521358/mmd-text-to-motion.git\"\n",
"\n",
"! python3.9 -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113\n",
"! python3.9 -m pip install --upgrade -r \"./mmd-text-to-motion/requirements.txt\"\n",
"! python -m spacy download en_core_web_sm\n",
"! BEZIER_NO_EXTENSION=true BEZIER_INSTALL_PREFIX=true python -m pip install bezier --no-binary=bezier\n",
"! pip install --upgrade -r \"./mmd-text-to-motion/requirements.txt\"\n",
"\n",
"! pip install moviepy==2.0.0.dev2\n",
"! pip install imageio-ffmpeg\n",
"! pip install google-cloud-secret-manager\n",
"! pip install deepl\n",
"# ----------------------------\n",
"\n",
"# GCP認証\n",
"from google.colab import auth\n",
"auth.authenticate_user()\n",
"\n",
"from google.cloud import secretmanager\n",
"\n",
"# 3.8系で使う\n",
"! python3.8 -m pip install moviepy==2.0.0.dev2\n",
"! python3.8 -m pip install imageio-ffmpeg\n",
"def access_secret(project_id, secret_name, version='latest'):\n",
" client = secretmanager.SecretManagerServiceClient()\n",
" name = client.secret_version_path(project_id, secret_name, version)\n",
" response = client.access_secret_version(request={\"name\":name})\n",
" payload = response.payload.data.decode(\"UTF-8\")\n",
" return payload\n",
"\n",
"# ----------------------------\n",
"\n",
Expand Down Expand Up @@ -797,7 +794,8 @@
"process_dir_path = f'/content/output/{process_dir_name}'\n",
"os.makedirs(process_dir_path, exist_ok=True)\n",
"\n",
"! cd /content/mmd-text-to-motion/src && python3.9 executor.py --seed $p_seed --seconds $p_seconds --num_repetitions $p_num_repetitions --text \"$p_prompt\" --parent-dir \"$process_dir_path\" --process text2move,mix,motion --verbose 20 --log-mode 0 --lang en\n",
"! export PYTHONIOENCODING=utf-8 \n",
"! cd /content/mmd-text-to-motion/src && python executor.py --seed $p_seed --seconds $p_seconds --num_repetitions $p_num_repetitions --text \"$p_prompt\" --translated_text \"$p_prompt\" --parent-dir \"$process_dir_path\" --process text2move,mix,motion --verbose 20 --log-mode 0 --lang en\n",
"\n",
"import os\n",
"if os.path.exists(\"/content/mmd-text-to-motion/log/quit.log\"):\n",
Expand Down

0 comments on commit e5b8f6f

Please sign in to comment.