Spaces:
Sleeping
Sleeping
Update app.py
Browse files"์ด๋ฏธ์ง๊ฐ ์์ผ๋ก ๋์ด๋์ด ๋ณด์ด๊ฒ"
app.py
CHANGED
@@ -4,10 +4,8 @@ import cv2
|
|
4 |
import numpy as np
|
5 |
from PIL import Image, ExifTags
|
6 |
|
7 |
-
# ๊ฐ์ฅ ๋จผ์ set_page_config() ํธ์ถ
|
8 |
st.set_page_config(page_title="๋ฅํ์ดํฌ ์ฌ์ ๋ฐฉ์ง ํํฐ(ํ
์คํธ)", layout="wide")
|
9 |
|
10 |
-
|
11 |
ga_code = """
|
12 |
<!-- Global site tag (gtag.js) - Google Analytics -->
|
13 |
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PZPBGNENQG"></script>
|
@@ -18,11 +16,8 @@ ga_code = """
|
|
18 |
gtag('config', 'G-PZPBGNENQG');
|
19 |
</script>
|
20 |
"""
|
21 |
-
|
22 |
-
# Streamlit์ GA ์ฝ๋ ์ฝ์
|
23 |
components.html(ga_code, height=0)
|
24 |
|
25 |
-
# ๋๋จธ์ง Streamlit ์ฝ๋
|
26 |
st.title("๋ฅํ์ดํฌ ์ฌ์ ๋ฐฉ์ง ํํฐ(ํ
์คํธ)")
|
27 |
st.markdown("")
|
28 |
st.markdown("<span style='font-size: 18px;'>์๋
ํ์ธ์! ์ ํฌ๋ ๋ฅํ์ดํฌ๋ก๋ถํฐ ์ฌ๋ฌ๋ถ์ ์ฌ์ง์ ๋ณดํธํ๋ ์๋ฃจ์
์ ๊ฐ๋ฐํ๊ณ ์์ต๋๋ค.</span>", unsafe_allow_html=True)
|
@@ -113,37 +108,31 @@ st.markdown(
|
|
113 |
color: #FF0080;
|
114 |
text-decoration: none;
|
115 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
</style>
|
117 |
""",
|
118 |
unsafe_allow_html=True,
|
119 |
)
|
120 |
|
121 |
def change_hair_to_blonde(image):
|
122 |
-
# Convert to OpenCV format
|
123 |
image = np.array(image)
|
124 |
-
# Convert the image to HSV color space
|
125 |
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
|
126 |
-
|
127 |
-
# Define the range for hair color (dark colors)
|
128 |
lower_hair = np.array([0, 0, 0])
|
129 |
upper_hair = np.array([180, 255, 30])
|
130 |
-
|
131 |
-
# Create a mask for hair
|
132 |
mask = cv2.inRange(hsv, lower_hair, upper_hair)
|
133 |
-
|
134 |
-
# Change hair color to blonde (light yellow)
|
135 |
hsv[mask > 0] = (30, 255, 200)
|
136 |
-
|
137 |
-
# Convert back to RGB color space
|
138 |
image_blonde = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
|
139 |
return image_blonde
|
140 |
|
141 |
def add_noise(image):
|
142 |
-
# Convert to OpenCV format
|
143 |
image_np = np.array(image)
|
144 |
-
# Generate random noise
|
145 |
noise = np.random.normal(0, 25, image_np.shape).astype(np.uint8)
|
146 |
-
# Add noise to the image
|
147 |
noisy_image = cv2.add(image_np, noise)
|
148 |
return noisy_image
|
149 |
|
@@ -173,7 +162,6 @@ if uploaded_file is not None:
|
|
173 |
|
174 |
st.write("์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค...")
|
175 |
|
176 |
-
# Save the original image as a numpy array
|
177 |
image_np = np.array(image)
|
178 |
|
179 |
col1, col2 = st.columns(2)
|
|
|
4 |
import numpy as np
|
5 |
from PIL import Image, ExifTags
|
6 |
|
|
|
7 |
st.set_page_config(page_title="๋ฅํ์ดํฌ ์ฌ์ ๋ฐฉ์ง ํํฐ(ํ
์คํธ)", layout="wide")
|
8 |
|
|
|
9 |
ga_code = """
|
10 |
<!-- Global site tag (gtag.js) - Google Analytics -->
|
11 |
<script async src="https://www.googletagmanager.com/gtag/js?id=G-PZPBGNENQG"></script>
|
|
|
16 |
gtag('config', 'G-PZPBGNENQG');
|
17 |
</script>
|
18 |
"""
|
|
|
|
|
19 |
components.html(ga_code, height=0)
|
20 |
|
|
|
21 |
st.title("๋ฅํ์ดํฌ ์ฌ์ ๋ฐฉ์ง ํํฐ(ํ
์คํธ)")
|
22 |
st.markdown("")
|
23 |
st.markdown("<span style='font-size: 18px;'>์๋
ํ์ธ์! ์ ํฌ๋ ๋ฅํ์ดํฌ๋ก๋ถํฐ ์ฌ๋ฌ๋ถ์ ์ฌ์ง์ ๋ณดํธํ๋ ์๋ฃจ์
์ ๊ฐ๋ฐํ๊ณ ์์ต๋๋ค.</span>", unsafe_allow_html=True)
|
|
|
108 |
color: #FF0080;
|
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>
|
119 |
""",
|
120 |
unsafe_allow_html=True,
|
121 |
)
|
122 |
|
123 |
def change_hair_to_blonde(image):
|
|
|
124 |
image = np.array(image)
|
|
|
125 |
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
|
|
|
|
|
126 |
lower_hair = np.array([0, 0, 0])
|
127 |
upper_hair = np.array([180, 255, 30])
|
|
|
|
|
128 |
mask = cv2.inRange(hsv, lower_hair, upper_hair)
|
|
|
|
|
129 |
hsv[mask > 0] = (30, 255, 200)
|
|
|
|
|
130 |
image_blonde = cv2.cvtColor(hsv, cv2.COLOR_HSV2RGB)
|
131 |
return image_blonde
|
132 |
|
133 |
def add_noise(image):
|
|
|
134 |
image_np = np.array(image)
|
|
|
135 |
noise = np.random.normal(0, 25, image_np.shape).astype(np.uint8)
|
|
|
136 |
noisy_image = cv2.add(image_np, noise)
|
137 |
return noisy_image
|
138 |
|
|
|
162 |
|
163 |
st.write("์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค...")
|
164 |
|
|
|
165 |
image_np = np.array(image)
|
166 |
|
167 |
col1, col2 = st.columns(2)
|