Spaces:
Runtime error
Runtime error
ThapeloAndrewSindane
commited on
Commit
•
3e42172
1
Parent(s):
f4fcb65
loading model with pipeline
Browse filesLoading dsfsi model with pipeline
app.py
CHANGED
@@ -160,7 +160,7 @@ model_2 = load_model(constants.MODEL_NAME, "model_v2.bin")
|
|
160 |
model_3 = load_model(constants.MODEL_NAME, "model_v3.bin")
|
161 |
openlid = load_model('laurievb/OpenLID', "model.bin")
|
162 |
nllb = load_model('facebook/fasttext-language-identification', "model.bin")
|
163 |
-
za_lid =
|
164 |
|
165 |
|
166 |
# @st.cache_resource
|
@@ -220,20 +220,22 @@ def compute(sentences, version = 'v3'):
|
|
220 |
for index, sent in enumerate(sentences):
|
221 |
|
222 |
output = model_choice.predict(sent)
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
#
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
237 |
|
238 |
|
239 |
labels = labels + [output_label]
|
|
|
160 |
model_3 = load_model(constants.MODEL_NAME, "model_v3.bin")
|
161 |
openlid = load_model('laurievb/OpenLID', "model.bin")
|
162 |
nllb = load_model('facebook/fasttext-language-identification', "model.bin")
|
163 |
+
za_lid = load_model_pipeline('dsfsi/za-lid-bert', "model.bin")
|
164 |
|
165 |
|
166 |
# @st.cache_resource
|
|
|
220 |
for index, sent in enumerate(sentences):
|
221 |
|
222 |
output = model_choice.predict(sent)
|
223 |
+
output_label = output['label']
|
224 |
+
output_prob = output['score']
|
225 |
+
output_label_language = output['label']
|
226 |
+
# output_label = output[0][0].split('__')[-1].replace('_Hans', '_Hani').replace('_Hant', '_Hani')
|
227 |
+
# output_prob = max(min(output[1][0], 1), 0)
|
228 |
+
# output_label_language = output_label.split('_')[0]
|
229 |
+
|
230 |
+
# # script control
|
231 |
+
# if version in ['v3', 'v2', 'openlid-201', 'nllb-218'] and output_label_language!= 'zxx':
|
232 |
+
# main_script, all_scripts = get_script(sent)
|
233 |
+
# output_label_script = output_label.split('_')[1]
|
234 |
+
|
235 |
+
# if output_label_script not in all_scripts:
|
236 |
+
# output_label_script = main_script
|
237 |
+
# output_label = f"und_{output_label_script}"
|
238 |
+
# output_prob = 0
|
239 |
|
240 |
|
241 |
labels = labels + [output_label]
|