IgnoreLee commited on
Commit
ab305df
·
1 Parent(s): ddd164a

Upload 11 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ font/NanumGothic.ttf filter=lfs diff=lfs merge=lfs -text
37
+ font/NanumGothicBold.ttf filter=lfs diff=lfs merge=lfs -text
38
+ font/NanumGothicExtraBold.ttf filter=lfs diff=lfs merge=lfs -text
39
+ font/NanumGothicLight.ttf filter=lfs diff=lfs merge=lfs -text
Image/0.jpg ADDED
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+
4
+ from libs import *
5
+
6
+
7
+ with gr.Blocks(title="수업 성적 확인") as demo:
8
+ gr.Markdown("수업 성적 확인을 위해, 수업과 이름 학번을 입력하세요.")
9
+
10
+ with gr.Row():
11
+ with gr.Column():
12
+ input_image = gr.Image(type='numpy',label="이미지 입력", image_mode='RGB')
13
+
14
+ with gr.Column():
15
+ guild_image = gr.Image(os.path.join("Image", "0.jpg"),type='numpy', label="정답 이미지", interactive=False)
16
+
17
+ with gr.Row():
18
+ image_button = gr.Button("이미지 유사도 평가")
19
+
20
+ with gr.Row():
21
+ data_output = gr.Text(label="유사도", interactive=False)
22
+
23
+
24
+
25
+ image_button.click(check_img,inputs=[input_image, guild_image], outputs = [data_output])
26
+
27
+
28
+ demo.launch()
font/NanumGothic.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48a28e97b34fc8e5b157657633670cd1b7de126cfc414da65ce9c3d5bc8be733
3
+ size 4691820
font/NanumGothicBold.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:454eb3f503f377782a99eb84fc4bb7dde22a0f075d41b47427737f2985053bc9
3
+ size 4642244
font/NanumGothicExtraBold.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0288775c8f021f327fd77f9eb251eea80e4601bbbb068478c7878caa23e8f92
3
+ size 4526920
font/NanumGothicLight.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da39544c39be58124a4fcb296eafc2bf73530b3dbd1b19aa802c5c3fd227e31c
3
+ size 1523188
libs/__init__.py ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+
2
+ from .utils import *
libs/__pycache__/__init__.cpython-37.pyc ADDED
Binary file (165 Bytes). View file
 
libs/__pycache__/utils.cpython-37.pyc ADDED
Binary file (1.41 kB). View file
 
libs/utils.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import cv2
3
+ import lpips
4
+ import torch
5
+ import numpy as np
6
+ import gradio as gr
7
+
8
+
9
+
10
+ SPATIAL = True
11
+ ALEXT = lpips.LPIPS(net='alex', spatial=SPATIAL)
12
+ VGG = lpips.LPIPS(net='vgg', spatial=SPATIAL)
13
+
14
+ def normalize(img, factor=255./2., cent= 1.):
15
+ r"""
16
+ Image Normalizagion
17
+ [H, W, C], scale : [0 - 1]
18
+ """
19
+ img = (img / factor - cent)
20
+ return img
21
+
22
+
23
+ def resize(img, resize=256):
24
+ r"""
25
+ Image Resize using cv2
26
+ """
27
+ return cv2.resize(img, (resize, resize))
28
+
29
+ def to_tensor(img):
30
+ r"""
31
+ make numpy to tensor
32
+ """
33
+ img = torch.Tensor(img[..., np.newaxis].transpose((3, 2, 0, 1)))
34
+ return img
35
+
36
+
37
+
38
+
39
+ def img_preprocessing(img):
40
+ img = resize(img)
41
+ img = normalize(img)
42
+ img = to_tensor(img)
43
+ return img
44
+
45
+ def check_img(input_img, gt_img):
46
+
47
+ # Preprocessing
48
+ input_img = img_preprocessing(input_img)
49
+ gt_img = img_preprocessing(gt_img)
50
+
51
+ # predict similarytiy
52
+ similarity = ALEXT.forward(gt_img, input_img)
53
+
54
+ if SPATIAL:
55
+ return f"{(1 - similarity.mean().item()) *100:.4f}%"
56
+ else:
57
+ return f"{(1 - similarity.item()) *100:.4f}%"
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ lpips
2
+ torch
3
+ opencv-python
4
+ matplotlib