Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -143,16 +143,25 @@ class SentenceBertJapanese:
|
|
143 |
|
144 |
st.title("いらすと検索")
|
145 |
description_text = st.empty()
|
146 |
-
description_text.text("...モデル読み込み中...")
|
147 |
|
148 |
-
model
|
|
|
|
|
|
|
149 |
|
150 |
-
pyminizip.uncompress(
|
151 |
-
|
152 |
-
)
|
153 |
-
|
154 |
-
df = pq.read_table("irasuto_items_20210224.parquet").to_pandas()
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
|
157 |
description_text.text("説明文の意味が近い「いらすとや」画像を検索します。\nキーワードを列挙するよりも、自然な文章を入力した方が精度よく検索できます。")
|
158 |
|
|
|
143 |
|
144 |
st.title("いらすと検索")
|
145 |
description_text = st.empty()
|
|
|
146 |
|
147 |
+
if "model" not in st.session_state:
|
148 |
+
description_text.text("...モデル読み込み中...")
|
149 |
+
model = SentenceBertJapanese("sonoisa/sentence-bert-base-ja-mean-tokens")
|
150 |
+
st.session_state.model = model
|
151 |
|
152 |
+
pyminizip.uncompress(
|
153 |
+
"irasuto_items_20210224.pq.zip", st.secrets["ZIP_PASSWORD"], None, 1
|
154 |
+
)
|
155 |
+
|
156 |
+
df = pq.read_table("irasuto_items_20210224.parquet").to_pandas()
|
157 |
+
st.session_state.df = df
|
158 |
+
|
159 |
+
sentence_vectors = np.stack(df["sentence_vector"])
|
160 |
+
st.session_state.sentence_vectors = sentence_vectors
|
161 |
+
|
162 |
+
model = st.session_state.model
|
163 |
+
df = st.session_state.df
|
164 |
+
sentence_vectors = st.session_state.sentence_vectors
|
165 |
|
166 |
description_text.text("説明文の意味が近い「いらすとや」画像を検索します。\nキーワードを列挙するよりも、自然な文章を入力した方が精度よく検索できます。")
|
167 |
|