kargaranamir HF Staff commited on
Commit
f365795
·
1 Parent(s): e4c022f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -10
app.py CHANGED
@@ -2,15 +2,6 @@ import streamlit as st
2
  from huggingface_hub import hf_hub_download
3
  from utils import *
4
 
5
- # Download the models
6
- HengamTransW = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransW.pth")
7
- HengamTransA = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransA.pth")
8
-
9
- # Load models lazily
10
- @st.cache(allow_output_mutation=True)
11
- def load_ner_model(model_path):
12
- return NER(model_path=model_path, tags=['B-TIM', 'I-TIM', 'B-DAT', 'I-DAT', 'O'])
13
-
14
  # APP
15
  st.set_page_config(
16
  page_title="Hengam",
@@ -40,6 +31,25 @@ with st.expander("ℹ️ - About this app", expanded=True):
40
  )
41
  st.markdown("")
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  st.markdown("")
44
  st.markdown("## **📌 Paste any Persian (Farsi) text you want to extract its temporal markers.**")
45
  with st.form(key="my_form"):
@@ -75,5 +85,5 @@ with st.form(key="my_form"):
75
  if submit_button:
76
  result = ner(doc)
77
  st.write("") # Add vertical spacing
78
- st.markdown("## **🎈Check results**")
79
  st.code(result, language="python")
 
2
  from huggingface_hub import hf_hub_download
3
  from utils import *
4
 
 
 
 
 
 
 
 
 
 
5
  # APP
6
  st.set_page_config(
7
  page_title="Hengam",
 
31
  )
32
  st.markdown("")
33
 
34
+ # Display initial loading message
35
+ st.write("Please wait while the model is loading...")
36
+
37
+ # Download the models
38
+ HengamTransW = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransW.pth")
39
+ HengamTransA = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransA.pth")
40
+
41
+
42
+ # Load models lazily
43
+ @st.cache(allow_output_mutation=True)
44
+ def load_ner_model(model_path):
45
+ return NER(model_path=model_path, tags=['B-TIM', 'I-TIM', 'B-DAT', 'I-DAT', 'O'])
46
+
47
+ # cache
48
+ load_ner_model(HengamTransW)
49
+ load_ner_model(HengamTransA)
50
+
51
+ st.empty() # Clear the "Please wait" message
52
+
53
  st.markdown("")
54
  st.markdown("## **📌 Paste any Persian (Farsi) text you want to extract its temporal markers.**")
55
  with st.form(key="my_form"):
 
85
  if submit_button:
86
  result = ner(doc)
87
  st.write("") # Add vertical spacing
88
+ st.markdown("##Result**")
89
  st.code(result, language="python")