File size: 8,001 Bytes
bbe1ed5 f586132 c98abc8 f586132 1a1812a f586132 1a1812a f586132 1a1812a f586132 1a1812a f586132 1a1812a f586132 1a1812a f586132 bbe1ed5 e1f10a7 f586132 e1f10a7 f586132 d34cf4e e1f10a7 f586132 ae4d776 f586132 ae4d776 f586132 1a1812a f586132 1a1812a f586132 1a1812a f586132 1a1812a 44f2452 efd1ae9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
import streamlit as st
import streamlit.components.v1 as components
import cv2
import numpy as np
from PIL import Image, ExifTags
# κ°μ₯ λ¨Όμ set_page_config() νΈμΆ
st.set_page_config(page_title="λ₯νμ΄ν¬ μ¬μ λ°©μ§ νν°(ν
μ€νΈ)", layout="wide")
ga_code = """
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PZPBGNENQG"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-PZPBGNENQG');
</script>
"""
# Streamlitμ GA μ½λ μ½μ
components.html(ga_code, height=0)
# λ°μν λμμΈμ μν CSS
css = """
<style>
.container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
align-items: center;
justify-items: center;
}
.custom-caption-1, .custom-caption-2 {
font-size: 20px;
font-weight: bold;
text-align: center;
margin-top: 10px;
color: white;
}
@media only screen and (max-width: 768px) {
.container {
grid-template-columns: 1fr;
}
.custom-caption-1, .custom-caption-2 {
font-size: 16px;
}
}
</style>
"""
# CSSλ₯Ό HTMLλ‘ μ½μ
st.markdown(css, unsafe_allow_html=True)
st.title("λ₯νμ΄ν¬ μ¬μ λ°©μ§ νν°(ν
μ€νΈ)")
st.markdown("")
st.markdown("<span style='font-size: 18px;'>μλ
νμΈμ! μ ν¬λ λ₯νμ΄ν¬λ‘λΆν° μ¬λ¬λΆμ μ¬μ§μ 보νΈνλ μ루μ
μ κ°λ°νκ³ μμ΅λλ€.</span>", unsafe_allow_html=True)
st.markdown("<span style='font-size: 18px;'>μ ν¬μ λͺ©νλ μ¨λΌμΈμ κ²μλ κ°μΈμ μ¬μ§μ΄ μ
μ± λ₯νμ΄ν¬ μμμ μ¬μ©λμ§ μλλ‘ νλ κ²μ
λλ€. νμ¬λ κ°λ°μ λ§λ¬΄λ¦¬νκ³ μλΉμ€ν νκΈ° μ , μ¬λ¬λΆμ μ견μ λ£κΈ° μν΄ κ°λ¨ν ν
μ€νΈλ₯Ό μ§ννκ³ μμ΅λλ€.</span>", unsafe_allow_html=True)
st.markdown("<span style='font-size: 18px;'>μ΅κ·Ό SNSμ μ
λ‘λλ μ΄λ―Έμ§κ° λ₯νμ΄ν¬ ν¬λ₯΄λ
Έλ¬Όμ μ
μ©λλ μ¬λ‘κ° λ§€μΌ λ³΄κ³ λκ³ μμ΅λλ€. λ°λΌμ ν΄κ²°μ±
μ κ°κ΅¬νκΈ° μν΄, μ¬λ¬λΆμ μμ€ν μκ²¬μ΄ νμν©λλ€.</span>", unsafe_allow_html=True)
st.markdown("<span style='font-size: 18px;'>μλ λ§ν¬λ₯Ό ν΅ν΄ μ ν¬ μλΉμ€λ₯Ό μ΄μ©ν΄ 보μ ν, μΈν°λ·°μ μ°Έμ¬ν΄ μ£Όμλ©΄ ν° λμμ΄ λκ² μ΅λλ€. μ¬λ¬λΆμ νΌλλ°±μ μλΉμ€ κ°μ μ κ·μ€ν μλ£κ° λ κ²μ
λλ€.</span>", unsafe_allow_html=True)
st.markdown("")
st.markdown("<span style='font-size: 18px;'>λμ μ리 : 1. μ΄λ―Έμ§λ₯Ό μ
λ‘λνλ©΄, μ¬μ λ°©μ§ νν°κ° μ μ©λ μ΄λ―Έμ§λ₯Ό 보μ¬λ립λλ€. 2. νλ¨μ ν° λ²νΌμ ν΄λ¦νλ©΄ λ₯νμ΄ν¬ λͺ¨λΈμ ν΅ν΄ μμ±λ κ²°κ³Όλ₯Ό νμΈν μ μμ΅λλ€.</span>", unsafe_allow_html=True)
st.markdown("<span style='font-size: 18px;'>μ¬λ¬λΆμ μ°Έμ¬μ κ°μ¬λ립λλ€!</span>", unsafe_allow_html=True)
st.markdown("<span style='font-size: 14px;'> *μ¬μ λ°©μ§ νν°λ: μ¬λ¬λΆμ μ¬μ§μ΄ λ₯νμ΄ν¬ λͺ¨λΈμ νμ΅λμ§ λͺ»νλλ‘ λ°©ν΄νλ λ
Έμ΄μ¦(noise)ννμ νν°.</span>", unsafe_allow_html=True)
def change_hair_to_blonde(image):
# Convert to OpenCV format
image = np.array(image)
# Convert the image to HSV color space
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
# Define the range for hair color (dark colors)
lower_hair = np.array([0, 0, 0])
upper_hair = np.array([180, 255, 30])
# Create a mask for hair
mask = cv2.inRange(hsv, lower_hair, upper_hair)
# Change hair color to blonde (light yellow)
hsv[mask > 0] = (30, 255, 200)
# Convert back to RGB color space
image_blonde = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
return image_blonde
def add_noise(image):
# Convert to OpenCV format
image_np = np.array(image)
# Generate random noise
noise = np.random.normal(0, 25, image_np.shape).astype(np.uint8)
# Add noise to the image
noisy_image = cv2.add(image_np, noise)
return noisy_image
def correct_image_orientation(image):
try:
for orientation in ExifTags.TAGS.keys():
if ExifTags.TAGS[orientation] == 'Orientation':
break
exif = image._getexif()
if exif is not None:
orientation = exif.get(orientation, 1)
if orientation == 3:
image = image.rotate(180, expand=True)
elif orientation == 6:
image = image.rotate(270, expand=True)
elif orientation == 8:
image = image.rotate(90, expand=True)
except (AttributeError, KeyError, IndexError):
pass
return image
uploaded_file = st.file_uploader("μ΄λ―Έμ§λ₯Ό μ
λ‘λνμΈμ...", type=["jpg", "png", "jpeg"])
if uploaded_file is not None:
image = Image.open(uploaded_file)
image = correct_image_orientation(image)
st.write("μ΄λ―Έμ§ μ²λ¦¬ μ€...")
# Save the original image as a numpy array
image_np = np.array(image)
st.markdown('<div class="container">', unsafe_allow_html=True)
st.markdown('<div>', unsafe_allow_html=True)
st.image(image, use_column_width=True)
st.markdown('<div class="custom-caption-1">μ
λ‘λν μ΄λ―Έμ§</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('<div>', unsafe_allow_html=True)
st.image(image, use_column_width=True)
st.markdown('<div class="custom-caption-1">νν°λ₯Ό μ
ν μ΄λ―Έμ§</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
button_clicked = st.button("μλ¨μ λ μ¬μ§μ λ₯νμ΄ν¬ λͺ¨λΈμ νμ΅μν€κΈ°")
if button_clicked:
st.markdown('<div class="container">', unsafe_allow_html=True)
st.markdown('<div>', unsafe_allow_html=True)
processed_image = change_hair_to_blonde(image)
st.image(processed_image, use_column_width=True)
st.markdown('<div class="custom-caption-2">μλ³Έ μ΄λ―Έμ§λ₯Ό λ₯νμ΄ν¬ λͺ¨λΈμ λ£μμ κ²½μ°</div>', unsafe_allow_html=True)
st.markdown("<span>μ΄ν΄λ₯Ό λκΈ° μν΄ μ¬μ§μ λ
Έλμμ μ
νλ λ₯νμ΄ν¬ μκ³ λ¦¬μ¦ μ μ©. μλ³Έ μ΄λ―Έμ§λ λ₯νμ΄ν¬ μκ³ λ¦¬μ¦μ μν₯μ λ°μ.</span>", unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('<div>', unsafe_allow_html=True)
deepfake_image = add_noise(image)
st.image(deepfake_image, use_column_width=True)
st.markdown('<div class="custom-caption-2">μ¬μ λ°©μ§ νν° μ΄λ―Έμ§λ₯Ό λ₯νμ΄ν¬ λͺ¨λΈμ λ£μμ κ²½μ°</div>', unsafe_allow_html=True)
st.markdown("<span>μ¬μ λ°©μ§ νν°λ₯Ό μ
ν μ΄λ―Έμ§λ λ₯νμ΄ν¬ μκ³ λ¦¬μ¦μ μν₯μ λ°μ§ μκ³ λ
Έμ΄μ¦ μ²λ¦¬κ° λμ΄ μμ보기 νλ μ¬μ§μ μΆλ ₯. μ¦, λ₯νμ΄ν¬ μ¬μ§ ν©μ±μ λ°©ν΄ν¨.</span>", unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
# μΈν°λ·° κ΄λ ¨ 문ꡬλ₯Ό λ²νΌ ν΄λ¦ ν μλμ νμ
st.markdown('<p class="survey">μ μλΉμ€λ₯Ό μ¬μ©ν΄ 보μ
¨κ±°λ, μ ν¬ κΈ°μ μ μ리μ κ΄μ¬μ΄ μμΌμ λΆλ€κ»μ μλμ κ°λ¨ν μΈν°λ·°μ μ°Έμ¬ν΄ μ£Όμλ©΄ μ§μ¬μΌλ‘ κ°μ¬λλ¦¬κ² μ΅λλ€.</p>', unsafe_allow_html=True)
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)
st.markdown('<p class="survey-2">μλΉμ€λ₯Ό μ΄μ©ν΄ μ£Όμ
μ κ°μ¬ν©λλ€! μ’μ ν루 보λ΄μΈμ!</p>', unsafe_allow_html=True)
|