1
1

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 1 year has passed since last update.

ベンチマークトップのモデルを使う

スクリーンショット 2023-10-25 11.57.10.png

インストール

git clone https://github.com/XPixelGroup/HAT.git
cd HAT
pip install -r requirements.txt
python setup.py develop

事前トレーニング済みモデルのダウンロード

pip install --upgrade gdown
gdown https://drive.google.com/u/0/uc?id=1Ma12vCWT27P9M99-s2RXnynKN-OQsBrv

リポジトリで提供されている事前トレーニング済みモデルはGoogle Driveにあります。

構成ファイルの書き換え

以下は、自分で用意した画像で実行する場合の手順です。

options/testにある該当モデルの構成ファイルの

path:
  pretrain_network_g: ./experiments/pretrained_models/Real_HAT_GAN_SRx4.pth

を先ほどダウンロードした事前トレーニング済みモデルファイルのパスに書き換えます。

datasetの項目を

datasets:
  test_1:  # the 1st test dataset
    name: custom
    type: SingleImageDataset
    dataroot_lq: input_dir
    io_backend:
      type: disk

に書き換え、datarootに自分が超解像したい画像を入れたディレクトリのパスを指定します。

valの項目を以下のみにします。

val:
  save_img: true
  suffix: ~  # add suffix to saved images, if None, use exp name

実行

上記で書き換えた構成ファイルを指定してテストを実行します。

python hat/test.py -opt options/test/HAT_GAN_Real_SRx4.yml

結果はresultsディレクトリに保存されます。

低解像度644*799

高解像度2576*3196

背景がくっきりしましたね。

CUDAのout of memoryが出た場合は、構成ファイルに以下を追加します。
インプット画像を小さく分割して実行します。

tile: # use the tile mode for limited GPU memory when testing.
  tile_size: 512 # the higher, the more utilized GPU memory and the less performance change against the full image. must be an integer multiple of the window size.
  tile_pad: 32 # overlapping between adjacency patches.must be an integer multiple of the window size.

🐣


フリーランスエンジニアです。
AIについて色々記事を書いていますのでよかったらプロフィールを見てみてください。

もし以下のようなご要望をお持ちでしたらお気軽にご相談ください。
AIサービスを開発したい、ビジネスにAIを組み込んで効率化したい、AIを使ったスマホアプリを開発したい、
ARを使ったアプリケーションを作りたい、スマホアプリを作りたいけどどこに相談したらいいかわからない…

いずれも中間コストを省いたリーズナブルな価格でお請けできます。

お仕事のご相談はこちらまで
rockyshikoku@gmail.com

機械学習やAR技術を使ったアプリケーションを作っています。
機械学習/AR関連の情報を発信しています。

Twitter
Medium
GitHub

1
1
0

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?