minju0730 commited on
Commit
f0e6dd9
ยท
verified ยท
1 Parent(s): a9f737a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -3
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
- st.image('photo4.jpeg', caption='์ถœ์ฒ˜ ์•ˆ์„ฑ๊ฒฝ์ฐฐ์„œ')
 
 
 
 
 
 
 
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
  ๋งค์žฅ ๋‚ด ์†๋‹˜์ด ๋ณธ์ธ์˜ ๋ชจ์Šต์„ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๊ฑฐ์šธ์„ ์„ค์น˜ํ•ด ์–‘์‹ฌ์˜ ๊ฐ€์ฑ…์„ ๋А๋ผ๊ณ  ์ถฉ๋™์  ๋ฒ”์ฃ„์š•๊ตฌ๋ฅผ ์ฐจ๋‹จํ•˜๋„๋ก ํ•œ๋‹ค.