byoonkim commited on
Commit
179812c
·
verified ·
1 Parent(s): f99ce05

Upload 4 files

Browse files
Files changed (3) hide show
  1. apt.txt +1 -0
  2. incheon_README.md +13 -0
  3. incheon_simulator_app.py +7 -6
apt.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ fonts-nanum
incheon_README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Incheon Citizen Attitude/Perception/Feeling Simulator
3
+ emoji: 🏙️
4
+ colorFrom: blue
5
+ colorTo: gray
6
+ sdk: streamlit
7
+ sdk_version: 1.31.0
8
+ app_file: incheon_simulator_app.py
9
+ pinned: false
10
+ ---
11
+
12
+ # Incheon Citizen Attitude/Perception/Feeling Simulator
13
+ This application simulates how Incheon citizens might react (attitude, perception, or feelings) to various issues, questions, or policies using the Nemotron-Personas-Korea dataset and Gemini AI. It allows for testing two different inputs on a single screen.
incheon_simulator_app.py CHANGED
@@ -5,9 +5,12 @@ st.set_page_config(page_title="인천 시민 정책 AI 시뮬레이터", layout=
5
 
6
  import pandas as pd
7
  import numpy as np
8
- from datasets import load_dataset
 
 
9
  import matplotlib.pyplot as plt
10
  import matplotlib.font_manager as fm
 
11
  import os
12
  import google.generativeai as genai
13
  import re # Import re for regex operations
@@ -15,11 +18,9 @@ import re # Import re for regex operations
15
  # --- Font and Environment Setup ---
16
  @st.cache_resource
17
  def setup_environment():
18
- # Check if font is already installed to prevent re-installation on rerun
19
- font_path = '/usr/share/fonts/truetype/nanum/NanumBarunGothic.ttf'
20
- if not os.path.exists(font_path):
21
- os.system('sudo apt-get install -y fonts-nanum')
22
- fm._rebuild()
23
  try:
24
  plt.rc('font', family='NanumBarunGothic')
25
  except Exception as e:
 
5
 
6
  import pandas as pd
7
  import numpy as np
8
+ # Set matplotlib backend BEFORE importing pyplot
9
+ import matplotlib
10
+ matplotlib.use('Agg')
11
  import matplotlib.pyplot as plt
12
  import matplotlib.font_manager as fm
13
+ from datasets import load_dataset
14
  import os
15
  import google.generativeai as genai
16
  import re # Import re for regex operations
 
18
  # --- Font and Environment Setup ---
19
  @st.cache_resource
20
  def setup_environment():
21
+ # The font will be installed via apt.txt on Hugging Face Spaces.
22
+ # We only need to rebuild the font cache and set the font for matplotlib here.
23
+ fm._rebuild()
 
 
24
  try:
25
  plt.rc('font', family='NanumBarunGothic')
26
  except Exception as e: