diff --git a/latent.ipynb b/latent.ipynb index f691d4e..39e71b4 100644 --- a/latent.ipynb +++ b/latent.ipynb @@ -1654,6 +1654,49 @@ " print(\"Downloaded as custom_settings.cfg\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Super Resolution with SwinIR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# SUPER RESOLUTION\n", + "\n", + "%cd /content\n", + "!git clone https://github.com/voodoohop/SwinIR\n", + "%cd /content/SwinIR\n", + "!wget -c \"https://github.com/JingyunLiang/SwinIR/releases/download/v0.0/003_realSR_BSRGAN_DFO_s64w8_SwinIR-M_x4_GAN.pth\" -P experiments/pretrained_models\n", + "\n", + "!pip install timm\n", + "!sudo apt install imagemagick\n", + "\n", + "from predict import Predictor\n", + "p = Predictor()\n", + "p.setup()\n", + "\n", + "from glob import glob\n", + "from tqdm import tqdm\n", + "\n", + "images = glob(f\"{outputs_path}/*.jpg\") + glob(f\"{outputs_path}/*.png\") + glob(f\"{outputs_path}/*.jpeg\")\n", + "images = list(sorted(images))\n", + "\n", + "tmp_output = \"/tmp/sr_output\"\n", + "!rm -rf $tmp_output\n", + "!mkdir -p $tmp_output\n", + "\n", + "for image_file in tqdm(images):\n", + " print(\"Upscaling\", image_file, \"with SwinIR\")\n", + " path = p.predict(image_file)\n", + " !mv \"{path}\" \"{image_file}\"\n" + ] + }, { "cell_type": "markdown", "metadata": {