hanriv commited on
Commit
b0233d9
ยท
verified ยท
1 Parent(s): 66420dd

Okey Dokey Yo

Files changed (1) hide show
  1. app.py +21 -6
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
+