Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ import requests
|
|
6 |
|
7 |
import streamlit
|
8 |
import spacy
|
|
|
9 |
from lxml import etree
|
10 |
import pandas as pd
|
11 |
|
@@ -27,9 +28,9 @@ ENTITY_COLORS = {
|
|
27 |
|
28 |
MAP_MODELS = {
|
29 |
"":"",
|
30 |
-
|
31 |
-
"fr_ner4archives_v3_default": "
|
32 |
-
"fr_ner4archives_v3_with_vectors":"
|
33 |
}
|
34 |
|
35 |
|
@@ -132,7 +133,7 @@ def main():
|
|
132 |
col2.text_area("Plain Text View (read-only)", value=plain, height=500, disabled=True)
|
133 |
flag_view = True
|
134 |
flag_model = False
|
135 |
-
|
136 |
if flag_view:
|
137 |
streamlit.write("## βοΈ Configure NER pipeline and options:")
|
138 |
streamlit.write(
|
@@ -146,53 +147,17 @@ def main():
|
|
146 |
model = option
|
147 |
model_loaded = None
|
148 |
if model != "":
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
except:
|
154 |
-
placeholder = streamlit.empty()
|
155 |
-
button = streamlit.button(f"Download model: {model}")
|
156 |
-
with placeholder.container():
|
157 |
-
if button:
|
158 |
-
streamlit.write(f"Download model: {model} in progress...")
|
159 |
-
p1 = subprocess.Popen(["pip", "install", MAP_MODELS[model]])
|
160 |
-
o = p1.wait()
|
161 |
-
if o == 0:
|
162 |
-
streamlit.write(f"Download model: {model} done.")
|
163 |
-
flag_model = True
|
164 |
-
streamlit.write(f"{model} is available locally.")
|
165 |
-
placeholder.empty()
|
166 |
-
|
167 |
-
if flag_model:
|
168 |
-
#gpu = streamlit.checkbox('Check to use GPU (if available)', value=False)
|
169 |
-
#gpu_icon = "β"
|
170 |
-
#if gpu:
|
171 |
-
# spacy.prefer_gpu()
|
172 |
-
# gpu_icon = "β
οΈ"
|
173 |
-
#else:
|
174 |
-
# spacy.require_cpu()
|
175 |
-
|
176 |
-
if is_entity_fishing_online():
|
177 |
-
streamlit.write("Entity-fishing server status: π’ (you can use linking feature)")
|
178 |
-
linking = streamlit.checkbox('Check to apply named entity linking (entity-fishing component)',
|
179 |
-
value=False)
|
180 |
-
linkingicon = "β
οΈ"
|
181 |
-
if linking is False:
|
182 |
-
linkingicon = "β"
|
183 |
-
else:
|
184 |
-
streamlit.write("Entity-fishing server status: π΄ (you can't use linking feature)")
|
185 |
-
linking = False
|
186 |
-
linkingicon = "β"
|
187 |
-
streamlit.write("#### Actual Parameters:")
|
188 |
-
streamlit.write(f'- NER model selected: {option}\n - Linking activated: {linkingicon} - GPU activated: {gpu_icon}')
|
189 |
|
|
|
190 |
# Launch NER process:
|
191 |
if flag_model:
|
192 |
if streamlit.button('Launch'):
|
193 |
plain = "\n".join(sentences)
|
194 |
with streamlit.spinner('Initialize NER...'):
|
195 |
-
nlp = spacy.load(model)
|
196 |
nlp.max_length = 5000000
|
197 |
if linking:
|
198 |
nlp.add_pipe('entityfishing',
|
@@ -266,4 +231,4 @@ def main():
|
|
266 |
|
267 |
|
268 |
if __name__ == "__main__":
|
269 |
-
main()
|
|
|
6 |
|
7 |
import streamlit
|
8 |
import spacy
|
9 |
+
|
10 |
from lxml import etree
|
11 |
import pandas as pd
|
12 |
|
|
|
28 |
|
29 |
MAP_MODELS = {
|
30 |
"":"",
|
31 |
+
"fr_ner4archives_V3_camembert_base": "./models_update/fr_ner4archives_V3_camembert_base-0.0.0",
|
32 |
+
"fr_ner4archives_v3_default": "./models_update/fr_ner4archives_v3_default-0.0.0",
|
33 |
+
"fr_ner4archives_v3_with_vectors":"./models_update/fr_ner4archives_v3_with_vectors-0.0.0"
|
34 |
}
|
35 |
|
36 |
|
|
|
133 |
col2.text_area("Plain Text View (read-only)", value=plain, height=500, disabled=True)
|
134 |
flag_view = True
|
135 |
flag_model = False
|
136 |
+
nlp = None
|
137 |
if flag_view:
|
138 |
streamlit.write("## βοΈ Configure NER pipeline and options:")
|
139 |
streamlit.write(
|
|
|
147 |
model = option
|
148 |
model_loaded = None
|
149 |
if model != "":
|
150 |
+
print(MAP_MODELS[model])
|
151 |
+
nlp = spacy.load(MAP_MODELS[model])
|
152 |
+
flag_model = True
|
153 |
+
streamlit.write(f"{model} is available locally.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
+
linking = False
|
156 |
# Launch NER process:
|
157 |
if flag_model:
|
158 |
if streamlit.button('Launch'):
|
159 |
plain = "\n".join(sentences)
|
160 |
with streamlit.spinner('Initialize NER...'):
|
|
|
161 |
nlp.max_length = 5000000
|
162 |
if linking:
|
163 |
nlp.add_pipe('entityfishing',
|
|
|
231 |
|
232 |
|
233 |
if __name__ == "__main__":
|
234 |
+
main()
|