Spaces:
Running
Running
Commit
·
e0d7f27
1
Parent(s):
f365795
Update app.py
Browse files
app.py
CHANGED
@@ -31,24 +31,22 @@ with st.expander("ℹ️ - About this app", expanded=True):
|
|
31 |
)
|
32 |
st.markdown("")
|
33 |
|
34 |
-
|
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 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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.**")
|
@@ -56,7 +54,6 @@ with st.form(key="my_form"):
|
|
56 |
c1, c2 = st.columns([2, 3])
|
57 |
|
58 |
with c1:
|
59 |
-
st.write("Please wait while loading the model...")
|
60 |
model_paths = {
|
61 |
"HengamTransW.pth": HengamTransW,
|
62 |
"HengamTransA.pth": HengamTransA,
|
@@ -71,7 +68,6 @@ with st.form(key="my_form"):
|
|
71 |
)
|
72 |
|
73 |
ner = load_ner_model(model_paths[ModelType])
|
74 |
-
st.empty() # Clear the "Please wait" message
|
75 |
|
76 |
with c2:
|
77 |
doc = st.text_area(
|
@@ -83,7 +79,7 @@ with st.form(key="my_form"):
|
|
83 |
submit_button = st.form_submit_button(label="✨ Extract Temporal Markers!")
|
84 |
|
85 |
if submit_button:
|
86 |
-
result = ner(doc)
|
87 |
st.write("") # Add vertical spacing
|
88 |
st.markdown("##Result**")
|
89 |
st.code(result, language="python")
|
|
|
31 |
)
|
32 |
st.markdown("")
|
33 |
|
34 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
# Load models lazily
|
36 |
@st.cache(allow_output_mutation=True)
|
37 |
def load_ner_model(model_path):
|
38 |
return NER(model_path=model_path, tags=['B-TIM', 'I-TIM', 'B-DAT', 'I-DAT', 'O'])
|
39 |
|
40 |
+
with st.spinner(text="Please wait while the model is loading...."):
|
41 |
+
|
42 |
+
# Download the models
|
43 |
+
HengamTransW = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransW.pth")
|
44 |
+
HengamTransA = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransA.pth")
|
45 |
+
|
46 |
+
# cache
|
47 |
+
load_ner_model(HengamTransW)
|
48 |
+
load_ner_model(HengamTransA)
|
49 |
|
|
|
50 |
|
51 |
st.markdown("")
|
52 |
st.markdown("## **📌 Paste any Persian (Farsi) text you want to extract its temporal markers.**")
|
|
|
54 |
c1, c2 = st.columns([2, 3])
|
55 |
|
56 |
with c1:
|
|
|
57 |
model_paths = {
|
58 |
"HengamTransW.pth": HengamTransW,
|
59 |
"HengamTransA.pth": HengamTransA,
|
|
|
68 |
)
|
69 |
|
70 |
ner = load_ner_model(model_paths[ModelType])
|
|
|
71 |
|
72 |
with c2:
|
73 |
doc = st.text_area(
|
|
|
79 |
submit_button = st.form_submit_button(label="✨ Extract Temporal Markers!")
|
80 |
|
81 |
if submit_button:
|
82 |
+
result = ner("# " + doc)
|
83 |
st.write("") # Add vertical spacing
|
84 |
st.markdown("##Result**")
|
85 |
st.code(result, language="python")
|