Spaces:
Sleeping
Sleeping
YES
Browse filesOkey Dokey Yo
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import cv2
|
3 |
import numpy as np
|
4 |
-
from PIL import Image
|
5 |
|
6 |
|
7 |
st.set_page_config(page_title="๋ฅํ์ดํฌ ์ฌ์ ๋ฐฉ์ง ํํฐ(ํ
์คํธ)", layout="wide")
|
@@ -121,10 +121,29 @@ def add_noise(image):
|
|
121 |
noisy_image = cv2.add(image_np, noise)
|
122 |
return noisy_image
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
uploaded_file = st.file_uploader("์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ์ธ์...", type=["jpg", "png", "jpeg"])
|
125 |
|
126 |
if uploaded_file is not None:
|
127 |
image = Image.open(uploaded_file)
|
|
|
128 |
|
129 |
st.write("์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค...")
|
130 |
|
@@ -141,9 +160,6 @@ if uploaded_file is not None:
|
|
141 |
st.image(image, use_column_width=True)
|
142 |
st.markdown('<div class="custom-caption-1">ํํฐ๋ฅผ ์
ํ ์ด๋ฏธ์ง</div>', unsafe_allow_html=True)
|
143 |
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
button_clicked = st.button("์๋จ์ ๋ ์ฌ์ง์ ๋ฅํ์ดํฌ ๋ชจ๋ธ์ ํ์ต์ํค๊ธฐ")
|
148 |
st.markdown('<p class="survey">์ ์๋น์ค๋ฅผ ์ฌ์ฉํด ๋ณด์
จ๊ฑฐ๋, ์ ํฌ ๊ธฐ์ ์ ์๋ฆฌ์ ๊ด์ฌ์ด ์์ผ์ ๋ถ๋ค๊ป์ ์๋์ ๊ฐ๋จํ ์ธํฐ๋ทฐ์ ์ฐธ์ฌํด ์ฃผ์๋ฉด ์ง์ฌ์ผ๋ก ๊ฐ์ฌ๋๋ฆฌ๊ฒ ์ต๋๋ค.</p>', unsafe_allow_html=True)
|
149 |
st.markdown('<p class="survey-1"><a href="https://docs.google.com/forms/d/e/1FAIpQLSdzRtuvQyp3CQDhlxEag40v2yDM7u9NYpJ2gv5kgwuNbo1gUA/viewform?usp=sf_link" target="_blank" class="a-tag">์ธํฐ๋ทฐ์ ์ํด ์ฃผ์ ๋ค๋ฉด ํฐ ๋์์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค!!</a></p>', unsafe_allow_html=True)
|
@@ -159,5 +175,4 @@ if uploaded_file is not None:
|
|
159 |
deepfake_image = add_noise(image)
|
160 |
st.image(deepfake_image, use_column_width=True)
|
161 |
st.markdown('<div class="custom-caption-2">์ฌ์ ๋ฐฉ์ง ํํฐ ์ด๋ฏธ์ง๋ฅผ ๋ฅํ์ดํฌ ๋ชจ๋ธ์ ๋ฃ์์ ๊ฒฝ์ฐ</div>', unsafe_allow_html=True)
|
162 |
-
|
163 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import cv2
|
3 |
import numpy as np
|
4 |
+
from PIL import Image, ExifTags
|
5 |
|
6 |
|
7 |
st.set_page_config(page_title="๋ฅํ์ดํฌ ์ฌ์ ๋ฐฉ์ง ํํฐ(ํ
์คํธ)", layout="wide")
|
|
|
121 |
noisy_image = cv2.add(image_np, noise)
|
122 |
return noisy_image
|
123 |
|
124 |
+
def correct_image_orientation(image):
|
125 |
+
try:
|
126 |
+
for orientation in ExifTags.TAGS.keys():
|
127 |
+
if ExifTags.TAGS[orientation] == 'Orientation':
|
128 |
+
break
|
129 |
+
exif = image._getexif()
|
130 |
+
if exif is not None:
|
131 |
+
orientation = exif.get(orientation, 1)
|
132 |
+
if orientation == 3:
|
133 |
+
image = image.rotate(180, expand=True)
|
134 |
+
elif orientation == 6:
|
135 |
+
image = image.rotate(270, expand=True)
|
136 |
+
elif orientation == 8:
|
137 |
+
image = image.rotate(90, expand=True)
|
138 |
+
except (AttributeError, KeyError, IndexError):
|
139 |
+
pass
|
140 |
+
return image
|
141 |
+
|
142 |
uploaded_file = st.file_uploader("์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ์ธ์...", type=["jpg", "png", "jpeg"])
|
143 |
|
144 |
if uploaded_file is not None:
|
145 |
image = Image.open(uploaded_file)
|
146 |
+
image = correct_image_orientation(image)
|
147 |
|
148 |
st.write("์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค...")
|
149 |
|
|
|
160 |
st.image(image, use_column_width=True)
|
161 |
st.markdown('<div class="custom-caption-1">ํํฐ๋ฅผ ์
ํ ์ด๋ฏธ์ง</div>', unsafe_allow_html=True)
|
162 |
|
|
|
|
|
|
|
163 |
button_clicked = st.button("์๋จ์ ๋ ์ฌ์ง์ ๋ฅํ์ดํฌ ๋ชจ๋ธ์ ํ์ต์ํค๊ธฐ")
|
164 |
st.markdown('<p class="survey">์ ์๋น์ค๋ฅผ ์ฌ์ฉํด ๋ณด์
จ๊ฑฐ๋, ์ ํฌ ๊ธฐ์ ์ ์๋ฆฌ์ ๊ด์ฌ์ด ์์ผ์ ๋ถ๋ค๊ป์ ์๋์ ๊ฐ๋จํ ์ธํฐ๋ทฐ์ ์ฐธ์ฌํด ์ฃผ์๋ฉด ์ง์ฌ์ผ๋ก ๊ฐ์ฌ๋๋ฆฌ๊ฒ ์ต๋๋ค.</p>', unsafe_allow_html=True)
|
165 |
st.markdown('<p class="survey-1"><a href="https://docs.google.com/forms/d/e/1FAIpQLSdzRtuvQyp3CQDhlxEag40v2yDM7u9NYpJ2gv5kgwuNbo1gUA/viewform?usp=sf_link" target="_blank" class="a-tag">์ธํฐ๋ทฐ์ ์ํด ์ฃผ์ ๋ค๋ฉด ํฐ ๋์์ด ๋ ๊ฒ ๊ฐ์ต๋๋ค!!</a></p>', unsafe_allow_html=True)
|
|
|
175 |
deepfake_image = add_noise(image)
|
176 |
st.image(deepfake_image, use_column_width=True)
|
177 |
st.markdown('<div class="custom-caption-2">์ฌ์ ๋ฐฉ์ง ํํฐ ์ด๋ฏธ์ง๋ฅผ ๋ฅํ์ดํฌ ๋ชจ๋ธ์ ๋ฃ์์ ๊ฒฝ์ฐ</div>', unsafe_allow_html=True)
|
178 |
+
|
|