Bingsu commited on
Commit
9c8a7bc
โ€ข
1 Parent(s): f0c8df9

fix: no double spinner

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -10,7 +10,7 @@ st.title("VitB32 Bert Ko Small Clip Test")
10
  st.markdown("Unsplash data์—์„œ ์ž…๋ ฅ ํ…์ŠคํŠธ์™€ ๊ฐ€์žฅ ์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€๋ฅผ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.")
11
 
12
 
13
- @st.cache(allow_output_mutation=True)
14
  def get_model():
15
  with st.spinner("Loading model..."):
16
  model = VisionTextDualEncoderModel.from_pretrained(
@@ -31,9 +31,7 @@ img_emb = np.load("img_emb.npy")
31
 
32
  text = st.text_input("Input Text", value="๊ฒ€์€ ๊ณ ์–‘์ด")
33
  tokens = processor(text=text, return_tensors="pt")
34
-
35
- with st.spinner("Predicting..."):
36
- text_emb = model.get_text_features(**tokens)
37
 
38
  result = semantic_search(text_emb, img_emb, top_k=15)[0]
39
  _result = iter(result)
 
10
  st.markdown("Unsplash data์—์„œ ์ž…๋ ฅ ํ…์ŠคํŠธ์™€ ๊ฐ€์žฅ ์œ ์‚ฌํ•œ ์ด๋ฏธ์ง€๋ฅผ ๊ฒ€์ƒ‰ํ•ฉ๋‹ˆ๋‹ค.")
11
 
12
 
13
+ @st.cache(allow_output_mutation=True, show_spinner=False)
14
  def get_model():
15
  with st.spinner("Loading model..."):
16
  model = VisionTextDualEncoderModel.from_pretrained(
 
31
 
32
  text = st.text_input("Input Text", value="๊ฒ€์€ ๊ณ ์–‘์ด")
33
  tokens = processor(text=text, return_tensors="pt")
34
+ text_emb = model.get_text_features(**tokens)
 
 
35
 
36
  result = semantic_search(text_emb, img_emb, top_k=15)[0]
37
  _result = iter(result)