Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,7 @@ import requests
|
|
| 8 |
import streamlit as st
|
| 9 |
from PIL import Image, ExifTags
|
| 10 |
|
|
|
|
| 11 |
def correct_image_orientation(image):
|
| 12 |
try:
|
| 13 |
for orientation in ExifTags.TAGS.keys():
|
|
@@ -25,7 +26,37 @@ def correct_image_orientation(image):
|
|
| 25 |
# cases: image don't have getexif
|
| 26 |
pass
|
| 27 |
return image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
st.markdown('# ๋์ด๋๋ ๋ฌด์ธ ์ ํฌ ์ ๋ ์
์ฃผ๋ค "ํผํด ๋ง๋งํด"')
|
| 30 |
|
| 31 |
st.write("<br><br><br>", unsafe_allow_html=True) # 3์ค ๋์ด์ฐ๊ธฐ
|
|
@@ -78,7 +109,7 @@ st.write("<br><br><br>", unsafe_allow_html=True)
|
|
| 78 |
|
| 79 |
# ์๋ํด๋ผ์ฐ๋
|
| 80 |
st.markdown("#### ๋ฌด์ธ์ ํฌ ์ฆ๊ฐ๋์ ๋น๋กํ๋ ์ ๋ ๋ฒ์ฃ")
|
| 81 |
-
st.write('์ฃผ์ ๋จ์ด๋ค์ ์๋ํด๋ผ์ฐ๋๋ก ๋ณด์ฌ์ฃผ๋ฉด ๋ค์๊ณผ ๊ฐ๋ค')
|
| 82 |
st.image('wordcloud.png', caption="'๋ฌด์ธ์ ํฌ'๋ฅผ ํค์๋๋ก 2023๋
๋ด์ค ๊ธฐ์ฌ ์น์คํฌ๋ํํ์ฌ ์ ์ํ ์๋ํด๋ผ์ฐ๋")
|
| 83 |
st.write('''ํค์๋์ธ ๋ฌด์ธ์ ํฌ๋ฅผ ์ ์ธํ๋ฉด ๋์งํธ, ๊ฒฝ์ฐฐ, ์ ๋ ์์ผ๋ก ๋จ์ด๊ฐ ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉ๋๋ค.
|
| 84 |
๋ฒ์ฃ ์ ํ์ ์ ๋๋ถํฐ ์ฌ๋ฌผ์๊ดด, ์ฐ๋ ๊ธฐ ๋ฌด๋จํฌ๊ธฐ ๋ฑ ๋ค์ํ ๋ฐฉ๋ฒ์ด ์กด์ฌํ๋๋ฐ ๋ฒ์ฃ์ ๊ด๋ จ๋ ์ถ์
, ์ฌ๋ฌผ, ํผ์, ์ฒญ์๋
, ๊ตฌ์ ๋ฑ ๊ด๋ จ ๋จ์ด๋ค์ ํ์ธํ ์ ์๋ค.
|
|
@@ -95,7 +126,7 @@ st.write("<br><br>", unsafe_allow_html=True)
|
|
| 95 |
|
| 96 |
# ์ง๋ html
|
| 97 |
st.write('''์ทจ์ฌํ์ ์ง์ญ๋ณ ๋ฌด์ธ์ ํฌ ์ ๋ ๋ฐ์ ๊ฑด์๋ฅผ ์ง๋๋ก ๋ํ๋ด ๋ณด์๋ค.
|
| 98 |
-
์ง๋ ๋ด ๊ฐ ์ง์ญ ์์ ๋ง์ฐ์ค๋ฅผ ๋์ผ๋ฉด ๊ด๋ จ ์ ๋ณด๊ฐ ๋ํ๋๋ค''')
|
| 99 |
with open('folium_map.html', 'r', encoding='utf-8') as f:
|
| 100 |
html_content2 = f.read()
|
| 101 |
st.components.v1.html(html_content2, height=500)
|
|
@@ -114,8 +145,16 @@ st.write('''๋ฌด์ธ์ ํฌ์ ์ ๋ ๋ฒ์ฃ ๋ฐ์๋ฅ ์ ๊ธ์ฆํ๋ ์ถ์ธ์ง๋ง
|
|
| 114 |
st.write("<br><br><br>", unsafe_allow_html=True)
|
| 115 |
|
| 116 |
st.markdown("#### ๋ฌด์ธ์ ํฌ ์ ๋๋ฅผ ๋ง๊ธฐ ์ํ ์ ์ฑ
๋ค์ํ... ์คํจ์ฑ์ ์์ด")
|
|
|
|
| 117 |
# ์์ฌ๊ฑฐ์ธ
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
st.write('''๋ฌด์ธ์ ํฌ ์ ๋์ ๋ฌด์์ด ์ฆ๊ฐ์ธ์ ๋ค์ํ ํด๊ฒฐ๋ฐฉ๋ฒ์ด ๋ฑ์ฅํ๊ณ ์๋ค.
|
| 120 |
๊ทธ ์ค ๊ฐ์ฅ ๋ง์ด ์๋ ค์ง ๊ฒ์ ์์ฌ๊ฑฐ์ธ ์ค์น๋ค.
|
| 121 |
๋งค์ฅ ๋ด ์๋์ด ๋ณธ์ธ์ ๋ชจ์ต์ ๋ณผ ์ ์๋ ๊ฑฐ์ธ์ ์ค์นํด ์์ฌ์ ๊ฐ์ฑ
์ ๋๋ผ๊ณ ์ถฉ๋์ ๋ฒ์ฃ์๊ตฌ๋ฅผ ์ฐจ๋จํ๋๋ก ํ๋ค.
|
|
|
|
| 8 |
import streamlit as st
|
| 9 |
from PIL import Image, ExifTags
|
| 10 |
|
| 11 |
+
# ์ด๋ฏธ์ง ํ์
|
| 12 |
def correct_image_orientation(image):
|
| 13 |
try:
|
| 14 |
for orientation in ExifTags.TAGS.keys():
|
|
|
|
| 26 |
# cases: image don't have getexif
|
| 27 |
pass
|
| 28 |
return image
|
| 29 |
+
|
| 30 |
+
import streamlit as st
|
| 31 |
+
from PIL import Image, ImageOps
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# ์ด๋ฏธ์ง ๊ฐ์ด๋ฐ ์ ๋ ฌ
|
| 35 |
+
def center_image(image, new_width, new_height):
|
| 36 |
+
"""
|
| 37 |
+
Center the image in a new blank canvas of specified size.
|
| 38 |
+
|
| 39 |
+
Args:
|
| 40 |
+
image (PIL.Image): The original image.
|
| 41 |
+
new_width (int): The width of the new canvas.
|
| 42 |
+
new_height (int): The height of the new canvas.
|
| 43 |
+
|
| 44 |
+
Returns:
|
| 45 |
+
PIL.Image: The centered image.
|
| 46 |
+
"""
|
| 47 |
+
# Create a new blank image with a white background
|
| 48 |
+
new_image = Image.new("RGB", (new_width, new_height), (255, 255, 255))
|
| 49 |
+
|
| 50 |
+
# Calculate the position to paste the original image onto the center of the new image
|
| 51 |
+
x_offset = (new_width - image.width) // 2
|
| 52 |
+
y_offset = (new_height - image.height) // 2
|
| 53 |
|
| 54 |
+
# Paste the original image onto the center of the new image
|
| 55 |
+
new_image.paste(image, (x_offset, y_offset))
|
| 56 |
+
|
| 57 |
+
return new_image
|
| 58 |
+
|
| 59 |
+
# ๊ธฐ์ฌ ์์
|
| 60 |
st.markdown('# ๋์ด๋๋ ๋ฌด์ธ ์ ํฌ ์ ๋ ์
์ฃผ๋ค "ํผํด ๋ง๋งํด"')
|
| 61 |
|
| 62 |
st.write("<br><br><br>", unsafe_allow_html=True) # 3์ค ๋์ด์ฐ๊ธฐ
|
|
|
|
| 109 |
|
| 110 |
# ์๋ํด๋ผ์ฐ๋
|
| 111 |
st.markdown("#### ๋ฌด์ธ์ ํฌ ์ฆ๊ฐ๋์ ๋น๋กํ๋ ์ ๋ ๋ฒ์ฃ")
|
| 112 |
+
st.write('์ฃผ์ ๋จ์ด๋ค์ ์๋ํด๋ผ์ฐ๋๋ก ๋ณด์ฌ์ฃผ๋ฉด ๋ค์๊ณผ ๊ฐ๋ค.')
|
| 113 |
st.image('wordcloud.png', caption="'๋ฌด์ธ์ ํฌ'๋ฅผ ํค์๋๋ก 2023๋
๋ด์ค ๊ธฐ์ฌ ์น์คํฌ๋ํํ์ฌ ์ ์ํ ์๋ํด๋ผ์ฐ๋")
|
| 114 |
st.write('''ํค์๋์ธ ๋ฌด์ธ์ ํฌ๋ฅผ ์ ์ธํ๋ฉด ๋์งํธ, ๊ฒฝ์ฐฐ, ์ ๋ ์์ผ๋ก ๋จ์ด๊ฐ ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉ๋๋ค.
|
| 115 |
๋ฒ์ฃ ์ ํ์ ์ ๋๋ถํฐ ์ฌ๋ฌผ์๊ดด, ์ฐ๋ ๊ธฐ ๋ฌด๋จํฌ๊ธฐ ๋ฑ ๋ค์ํ ๋ฐฉ๋ฒ์ด ์กด์ฌํ๋๋ฐ ๋ฒ์ฃ์ ๊ด๋ จ๋ ์ถ์
, ์ฌ๋ฌผ, ํผ์, ์ฒญ์๋
, ๊ตฌ์ ๋ฑ ๊ด๋ จ ๋จ์ด๋ค์ ํ์ธํ ์ ์๋ค.
|
|
|
|
| 126 |
|
| 127 |
# ์ง๋ html
|
| 128 |
st.write('''์ทจ์ฌํ์ ์ง์ญ๋ณ ๋ฌด์ธ์ ํฌ ์ ๋ ๋ฐ์ ๊ฑด์๋ฅผ ์ง๋๋ก ๋ํ๋ด ๋ณด์๋ค.
|
| 129 |
+
์ง๋ ๋ด ๊ฐ ์ง์ญ ์์ ๋ง์ฐ์ค๋ฅผ ๋์ผ๋ฉด ๊ด๋ จ ์ ๋ณด๊ฐ ๋ํ๋๋ค.''')
|
| 130 |
with open('folium_map.html', 'r', encoding='utf-8') as f:
|
| 131 |
html_content2 = f.read()
|
| 132 |
st.components.v1.html(html_content2, height=500)
|
|
|
|
| 145 |
st.write("<br><br><br>", unsafe_allow_html=True)
|
| 146 |
|
| 147 |
st.markdown("#### ๋ฌด์ธ์ ํฌ ์ ๋๋ฅผ ๋ง๊ธฐ ์ํ ์ ์ฑ
๋ค์ํ... ์คํจ์ฑ์ ์์ด")
|
| 148 |
+
|
| 149 |
# ์์ฌ๊ฑฐ์ธ
|
| 150 |
+
image_path = 'photo4.jpeg'
|
| 151 |
+
image = Image.open(image_path)
|
| 152 |
+
new_width = 800
|
| 153 |
+
new_height = 800
|
| 154 |
+
centered_image = center_image(image, new_width, new_height)
|
| 155 |
+
|
| 156 |
+
st.image(centered_image, caption='์ถ์ฒ ์์ฑ๊ฒฝ์ฐฐ์', use_column_width=True)
|
| 157 |
+
|
| 158 |
st.write('''๋ฌด์ธ์ ํฌ ์ ๋์ ๋ฌด์์ด ์ฆ๊ฐ์ธ์ ๋ค์ํ ํด๊ฒฐ๋ฐฉ๋ฒ์ด ๋ฑ์ฅํ๊ณ ์๋ค.
|
| 159 |
๊ทธ ์ค ๊ฐ์ฅ ๋ง์ด ์๋ ค์ง ๊ฒ์ ์์ฌ๊ฑฐ์ธ ์ค์น๋ค.
|
| 160 |
๋งค์ฅ ๋ด ์๋์ด ๋ณธ์ธ์ ๋ชจ์ต์ ๋ณผ ์ ์๋ ๊ฑฐ์ธ์ ์ค์นํด ์์ฌ์ ๊ฐ์ฑ
์ ๋๋ผ๊ณ ์ถฉ๋์ ๋ฒ์ฃ์๊ตฌ๋ฅผ ์ฐจ๋จํ๋๋ก ํ๋ค.
|