4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TecoGAN で低解像度の動画を高解像度化

Last updated at Posted at 2021-04-14

TecoGAN で低解像度の動画を高解像度化します。

環境はUbuntu20になります。
結構重いので、GPUを使うか、事前にffmpegで動画を縮小すると良いかもしれません。

install_tecogan.sh
#!/usr/bin/bash

# ==========================================================
# TecoGan 用に python3.6.8 を仮想環境にインストール
# ==========================================================
sudo echo ;
sudo apt-get install ffmpeg ;
sudo apt-get install python3-venv ;
sudo apt install -y \
  build-essential   \
  libffi-dev        \
  libssl-dev        \
  zlib1g-dev        \
  liblzma-dev       \
  libbz2-dev        \
  libreadline-dev   \
  libsqlite3-dev    \
  git ;
git clone https://github.com/pyenv/pyenv.git ~/.pyenv ;
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc ;
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc ;
echo 'eval "$(pyenv init -)"' >> ~/.bashrc ;
source ~/.bashrc ;
pyenv -v ;
pyenv install 3.6.8 ;
pyenv local 3.6.8 ;
pyenv versions ;

# ==========================================================
# TecoGAN のインストール
# ==========================================================
git clone https://github.com/thunil/TecoGAN ;
cd TecoGAN ;
python3 -m venv myvenv-topgan ;
source myvenv-topgan/bin/activate ;
python -m pip install pip -U ;
python -m pip install -r requirements.txt ;
python -m pip uninstall -y Keras Keras-Applications Keras-Preprocessing ;
python -m pip install keras==2.3.1 ;
python -m pip install tensorflow-gpu==1.14.0 ;
python runGan.py 0 ; # ライブラリ群をダウンロード
python runGan.py 1 ; # サンプルとして、LR/calendar に入っている画像を results/calendar に出力します。
# checck LR/calendar/*.png
# checck results/calendar/*.png

# ==========================================================
# 動画のダウンロードと動画を画像群化
# ==========================================================

# 動画のダウンロード(できればサイズは横幅240程度が望ましい)
# youtube-dl がない場合は下記コマンドでインストール
# sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl ;
# sudo chmod a+rx /usr/local/bin/youtube-dl ;
youtube-dl https://www.youtube.com/watch?v=RmlSsON0oY0 ;

# 一旦前回分の削除
mkdir LR/calendar_back ;
cp LR/calendar/* LR/calendar_back ;
rm LR/calendar/*
rm results/calendar/* ;

# 動画を画像群化
ffmpeg -i "ドリフ大爆笑1983年op-RmlSsON0oY0.mkv" -vcodec png LR/calendar/%d.png ;

# 縮小して使用する場合
# ffmpeg -i "ドリフ大爆笑1983年op-RmlSsON0oY0.mkv" -vf scale=120:-1 "低解像度動画.mkv" ;
# ffmpeg -i "低解像度動画.mkv" -vcodec png LR/calendar/%d.png ;

# TecoGAN の実行
python runGan.py 1 ;
# checck results/calendar/*.png

# 画像群を動画化
ffmpeg -i results/calendar/output_%d.png -vcodec libx264 -pix_fmt yuv420p "最終結果動画.mp4" ;

####参考リンク

あとで記載します。

4
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?