minhwai commited on
Commit
6811e34
ยท
verified ยท
1 Parent(s): 1a42495

Update app.py

Browse files

"๋งˆ์ง€๋ง‰"

Files changed (1) hide show
  1. app.py +62 -26
app.py CHANGED
@@ -47,18 +47,16 @@ st.markdown(
47
  gap: 20px;
48
  }
49
  .custom-caption-1 {
50
- font-size: 36px;
51
  font-weight: bold;
52
  text-align: center;
53
  margin-top: 10px;
54
- padding: 0 0 200px 0;
55
  }
56
  .custom-caption-2 {
57
- font-size: 36px;
58
  font-weight: bold;
59
  text-align: center;
60
  margin-top: 10px;
61
- padding: 0 0 30px 0;
62
  }
63
  .button-container {
64
  text-align: center;
@@ -109,10 +107,26 @@ st.markdown(
109
  text-decoration: none;
110
  }
111
  @media only screen and (max-width: 768px) {
112
- .column-container {
 
 
 
 
 
 
 
 
 
 
 
113
  display: flex;
114
  flex-direction: row;
115
  justify-content: center;
 
 
 
 
 
116
  }
117
  }
118
  </style>
@@ -163,31 +177,53 @@ if uploaded_file is not None:
163
  st.write("์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ ์ค‘...")
164
 
165
  image_np = np.array(image)
 
 
166
 
167
- col1, col2 = st.columns(2)
168
-
169
- with col1:
170
- st.image(image, use_column_width=True)
171
- st.markdown('<div class="custom-caption-1">์—…๋กœ๋“œํ•œ ์ด๋ฏธ์ง€</div>', unsafe_allow_html=True)
 
 
 
 
172
 
173
- with col2:
174
- st.image(image, use_column_width=True)
175
- st.markdown('<div class="custom-caption-1">ํ•„ํ„ฐ๋ฅผ ์ž…ํžŒ ์ด๋ฏธ์ง€</div>', unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
176
 
177
  button_clicked = st.button("์ƒ๋‹จ์˜ ๋‘ ์‚ฌ์ง„์„ ๋”ฅํŽ˜์ดํฌ ๋ชจ๋ธ์— ํ•™์Šต์‹œํ‚ค๊ธฐ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  st.markdown('<p class="survey">์œ„ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•ด ๋ณด์…จ๊ฑฐ๋‚˜, ์ €ํฌ ๊ธฐ์ˆ ์  ์›๋ฆฌ์— ๊ด€์‹ฌ์ด ์žˆ์œผ์‹  ๋ถ„๋“ค๊ป˜์„  ์•„๋ž˜์˜ ๊ฐ„๋‹จํ•œ ์ธํ„ฐ๋ทฐ์— ์ฐธ์—ฌํ•ด ์ฃผ์‹œ๋ฉด ์ง„์‹ฌ์œผ๋กœ ๊ฐ์‚ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.</p>', unsafe_allow_html=True)
179
  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)
180
  st.markdown('<p class="survey-2">์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ์ข‹์€ ํ•˜๋ฃจ ๋ณด๋‚ด์„ธ์š”!</p>', unsafe_allow_html=True)
181
-
182
- if button_clicked:
183
- with col1:
184
- processed_image = change_hair_to_blonde(image)
185
- st.image(processed_image, use_column_width=True)
186
- st.markdown('<div class="custom-caption-2">์›๋ณธ ์ด๋ฏธ์ง€๋ฅผ ๋”ฅํŽ˜์ดํฌ ๋ชจ๋ธ์— ๋„ฃ์—ˆ์„ ๊ฒฝ์šฐ</div>', unsafe_allow_html=True)
187
- st.markdown("<span>์ดํ•ด๋ฅผ ๋•๊ธฐ ์œ„ํ•ด ์‚ฌ์ง„์— ๋…ธ๋ž€์ƒ‰์„ ์ž…ํžˆ๋Š” ๋”ฅํŽ˜์ดํฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ ์šฉ. ์›๋ณธ ์ด๋ฏธ์ง€๋Š” ๋”ฅํŽ˜์ดํฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์˜ํ–ฅ์„ ๏ฟฝ๏ฟฝ๏ฟฝ์Œ.</span>", unsafe_allow_html=True)
188
-
189
- with col2:
190
- deepfake_image = add_noise(image)
191
- st.image(deepfake_image, use_column_width=True)
192
- st.markdown('<div class="custom-caption-2">์‚ฌ์ „ ๋ฐฉ์ง€ ํ•„ํ„ฐ ์ด๋ฏธ์ง€๋ฅผ ๋”ฅํŽ˜์ดํฌ ๋ชจ๋ธ์— ๋„ฃ์—ˆ์„ ๊ฒฝ์šฐ</div>', unsafe_allow_html=True)
193
- st.markdown("<span>์‚ฌ์ „ ๋ฐฉ์ง€ ํ•„ํ„ฐ๋ฅผ ์ž…ํžŒ ์ด๋ฏธ์ง€๋Š” ๋”ฅํŽ˜์ดํฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š๊ณ  ๋…ธ์ด์ฆˆ ์ฒ˜๋ฆฌ๊ฐ€ ๋˜์–ด ์•Œ์•„๋ณด๊ธฐ ํž˜๋“  ์‚ฌ์ง„์„ ์ถœ๋ ฅ. ์ฆ‰, ๋”ฅํŽ˜์ดํฌ ์‚ฌ์ง„ ํ•ฉ์„ฑ์„ ๋ฐฉํ•ดํ•จ.</span>", unsafe_allow_html=True)
 
47
  gap: 20px;
48
  }
49
  .custom-caption-1 {
50
+ font-size: 24px;
51
  font-weight: bold;
52
  text-align: center;
53
  margin-top: 10px;
 
54
  }
55
  .custom-caption-2 {
56
+ font-size: 24px;
57
  font-weight: bold;
58
  text-align: center;
59
  margin-top: 10px;
 
60
  }
61
  .button-container {
62
  text-align: center;
 
107
  text-decoration: none;
108
  }
109
  @media only screen and (max-width: 768px) {
110
+ .img-grid {
111
+ display: flex;
112
+ flex-direction: column;
113
+ align-items: center;
114
+ }
115
+ .img-grid img {
116
+ width: 90%;
117
+ height: auto;
118
+ }
119
+ }
120
+ @media only screen and (min-width: 769px) {
121
+ .img-grid {
122
  display: flex;
123
  flex-direction: row;
124
  justify-content: center;
125
+ gap: 10px;
126
+ }
127
+ .img-grid img {
128
+ width: 100%;
129
+ height: auto;
130
  }
131
  }
132
  </style>
 
177
  st.write("์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ ์ค‘...")
178
 
179
  image_np = np.array(image)
180
+ processed_image = change_hair_to_blonde(image)
181
+ deepfake_image = add_noise(image)
182
 
183
+ def image_to_base64(image):
184
+ from io import BytesIO
185
+ import base64
186
+ buffered = BytesIO()
187
+ image.save(buffered, format="PNG")
188
+ return base64.b64encode(buffered.getvalue()).decode()
189
+
190
+ image_base64 = image_to_base64(image)
191
+ processed_image_base64 = image_to_base64(Image.fromarray(processed_image))
192
 
193
+ components.html(f"""
194
+ <div class="img-grid">
195
+ <div>
196
+ <img src="data:image/png;base64,{image_base64}" />
197
+ <div class="custom-caption-1">์—…๋กœ๋“œํ•œ ์ด๋ฏธ์ง€</div>
198
+ </div>
199
+ <div>
200
+ <img src="data:image/png;base64,{processed_image_base64}" />
201
+ <div class="custom-caption-1">ํ•„ํ„ฐ๋ฅผ ์ž…ํžŒ ์ด๋ฏธ์ง€</div>
202
+ </div>
203
+ </div>
204
+ """, height=600)
205
 
206
  button_clicked = st.button("์ƒ๋‹จ์˜ ๋‘ ์‚ฌ์ง„์„ ๋”ฅํŽ˜์ดํฌ ๋ชจ๋ธ์— ํ•™์Šต์‹œํ‚ค๊ธฐ")
207
+
208
+ if button_clicked:
209
+ processed_image_base64 = image_to_base64(Image.fromarray(processed_image))
210
+ deepfake_image_base64 = image_to_base64(Image.fromarray(deepfake_image))
211
+
212
+ components.html(f"""
213
+ <div class="img-grid">
214
+ <div>
215
+ <img src="data:image/png;base64,{processed_image_base64}" />
216
+ <div class="custom-caption-2">์›๋ณธ ์ด๋ฏธ์ง€๋ฅผ ๋”ฅํŽ˜์ดํฌ ๋ชจ๋ธ์— ๋„ฃ์—ˆ์„ ๊ฒฝ์šฐ</div>
217
+ <span>์ดํ•ด๋ฅผ ๋•๊ธฐ ์œ„ํ•ด ์‚ฌ์ง„์— ๋…ธ๋ž€์ƒ‰์„ ์ž…ํžˆ๋Š” ๋”ฅํŽ˜์ดํฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ ์šฉ. ์›๋ณธ ์ด๋ฏธ์ง€๋Š” ๋”ฅํŽ˜์ดํฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์˜ํ–ฅ์„ ๋ฐ›์Œ.</span>
218
+ </div>
219
+ <div>
220
+ <img src="data:image/png;base64,{deepfake_image_base64}" />
221
+ <div class="custom-caption-2">์‚ฌ์ „ ๋ฐฉ์ง€ ํ•„ํ„ฐ ์ด๋ฏธ์ง€๋ฅผ ๋”ฅํŽ˜์ดํฌ ๋ชจ๋ธ์— ๋„ฃ์—ˆ์„ ๊ฒฝ์šฐ</div>
222
+ <span>์‚ฌ์ „ ๋ฐฉ์ง€ ํ•„ํ„ฐ๋ฅผ ์ž…ํžŒ ์ด๋ฏธ์ง€๋Š” ๋”ฅํŽ˜์ดํฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š๊ณ  ๋…ธ์ด์ฆˆ ์ฒ˜๋ฆฌ๊ฐ€ ๋˜์–ด ์•Œ์•„๋ณด๊ธฐ ํž˜๋“  ์‚ฌ์ง„์„ ์ถœ๋ ฅ. ์ฆ‰, ๋”ฅํŽ˜์ดํฌ ์‚ฌ์ง„ ํ•ฉ์„ฑ์„ ๋ฐฉํ•ดํ•จ.</span>
223
+ </div>
224
+ </div>
225
+ """, height=600)
226
+
227
  st.markdown('<p class="survey">์œ„ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•ด ๋ณด์…จ๊ฑฐ๋‚˜, ์ €ํฌ ๊ธฐ์ˆ ์  ์›๋ฆฌ์— ๊ด€์‹ฌ์ด ์žˆ์œผ์‹  ๋ถ„๋“ค๊ป˜์„  ์•„๋ž˜์˜ ๊ฐ„๋‹จํ•œ ์ธํ„ฐ๋ทฐ์— ์ฐธ์—ฌํ•ด ์ฃผ์‹œ๋ฉด ์ง„์‹ฌ์œผ๋กœ ๊ฐ์‚ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.</p>', unsafe_allow_html=True)
228
  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)
229
  st.markdown('<p class="survey-2">์„œ๋น„์Šค๋ฅผ ์ด์šฉํ•ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ์ข‹์€ ํ•˜๋ฃจ ๋ณด๋‚ด์„ธ์š”!</p>', unsafe_allow_html=True)