김재형

Bicubic Downsampling 코드 추가

1 +{
2 + "cells": [
3 + {
4 + "cell_type": "code",
5 + "execution_count": 1,
6 + "id": "ahead-paste",
7 + "metadata": {},
8 + "outputs": [],
9 + "source": [
10 + "from glob import glob\n",
11 + "import cv2\n",
12 + "\n",
13 + "images = sorted(glob(\"../bbb_sunflower_540p/*.png\"))"
14 + ]
15 + },
16 + {
17 + "cell_type": "code",
18 + "execution_count": 2,
19 + "id": "rapid-tension",
20 + "metadata": {},
21 + "outputs": [],
22 + "source": [
23 + "from pathlib import Path\n",
24 + "Path(\"../dataset/DIV2K/DIV2K_train_HR\").mkdir(parents=True, exist_ok=True)\n",
25 + "Path(\"../dataset/DIV2K/DIV2K_train_LR_bicubic/X2\").mkdir(parents=True, exist_ok=True)"
26 + ]
27 + },
28 + {
29 + "cell_type": "code",
30 + "execution_count": 3,
31 + "id": "visible-texas",
32 + "metadata": {},
33 + "outputs": [
34 + {
35 + "name": "stderr",
36 + "output_type": "stream",
37 + "text": [
38 + "100%|██████████| 1800/1800 [01:21<00:00, 22.00it/s]\n"
39 + ]
40 + }
41 + ],
42 + "source": [
43 + "from tqdm import tqdm\n",
44 + "for image in tqdm(images):\n",
45 + " hr = cv2.imread(image, cv2.IMREAD_COLOR)\n",
46 + " lr = cv2.resize(hr, dsize=(480, 270), interpolation=cv2.INTER_CUBIC)\n",
47 + "\n",
48 + " cv2.imwrite(\"../dataset/DIV2K/DIV2K_train_HR/\" + Path(image).name, hr)\n",
49 + " cv2.imwrite(\"../dataset/DIV2K/DIV2K_train_LR_bicubic/X2/\" + Path(image).stem + \"x2.png\", lr)"
50 + ]
51 + },
52 + {
53 + "cell_type": "code",
54 + "execution_count": null,
55 + "id": "fallen-religion",
56 + "metadata": {},
57 + "outputs": [],
58 + "source": []
59 + }
60 + ],
61 + "metadata": {
62 + "kernelspec": {
63 + "display_name": "Python 3",
64 + "language": "python",
65 + "name": "python3"
66 + },
67 + "language_info": {
68 + "codemirror_mode": {
69 + "name": "ipython",
70 + "version": 3
71 + },
72 + "file_extension": ".py",
73 + "mimetype": "text/x-python",
74 + "name": "python",
75 + "nbconvert_exporter": "python",
76 + "pygments_lexer": "ipython3",
77 + "version": "3.7.7"
78 + }
79 + },
80 + "nbformat": 4,
81 + "nbformat_minor": 5
82 +}