김재형

PSNR 계산 코드 추가

1 +{
2 + "cells": [
3 + {
4 + "cell_type": "code",
5 + "execution_count": 15,
6 + "id": "automotive-circus",
7 + "metadata": {},
8 + "outputs": [],
9 + "source": [
10 + "from glob import glob\n",
11 + "import cv2\n",
12 + "from tqdm import tqdm\n",
13 + "\n",
14 + "gt_list = sorted(glob(\"../bbb_sunflower_1080p/*.png\"))\n",
15 + "sr_list = sorted(glob(\"./experiment/test/results-Demo/*.png\"))"
16 + ]
17 + },
18 + {
19 + "cell_type": "code",
20 + "execution_count": 16,
21 + "id": "unique-wichita",
22 + "metadata": {},
23 + "outputs": [
24 + {
25 + "name": "stderr",
26 + "output_type": "stream",
27 + "text": [
28 + "100%|██████████| 1800/1800 [02:55<00:00, 10.24it/s]\n"
29 + ]
30 + }
31 + ],
32 + "source": [
33 + "with open(\"result.csv\", \"w\") as f:\n",
34 + " f.write(\"idx,psnr\\n\");\n",
35 + " for idx, (gt, sr) in tqdm(enumerate(zip(gt_list, sr_list)), total=len(sr_list)):\n",
36 + " gt_img = cv2.imread(gt)\n",
37 + " sr_img = cv2.imread(sr)\n",
38 + " psnr = cv2.PSNR(gt_img, sr_img)\n",
39 + " f.write(f\"{idx},{psnr}\\n\")"
40 + ]
41 + },
42 + {
43 + "cell_type": "code",
44 + "execution_count": null,
45 + "id": "raised-projector",
46 + "metadata": {},
47 + "outputs": [],
48 + "source": []
49 + }
50 + ],
51 + "metadata": {
52 + "kernelspec": {
53 + "display_name": "Python 3",
54 + "language": "python",
55 + "name": "python3"
56 + },
57 + "language_info": {
58 + "codemirror_mode": {
59 + "name": "ipython",
60 + "version": 3
61 + },
62 + "file_extension": ".py",
63 + "mimetype": "text/x-python",
64 + "name": "python",
65 + "nbconvert_exporter": "python",
66 + "pygments_lexer": "ipython3",
67 + "version": "3.7.7"
68 + }
69 + },
70 + "nbformat": 4,
71 + "nbformat_minor": 5
72 +}