ThapeloAndrewSindane commited on
Commit
deeaaa7
1 Parent(s): e57eb3d

Update all model calls

Browse files

Calling all models created as list of tuples

Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -253,12 +253,12 @@ def compute(sentences, version = 'v3'):
253
  model_choice = model_afrolm
254
  elif version == 'BERT':
255
  model_choice = za_lid
256
- elif version == 'OpenLID':
257
  model_choice = openlid
258
  elif version == 'GlotLID v3':
259
  model_choice = glotlid_3
260
  else:
261
- model_choice = [model_xlmr_large,model_serengeti, model_afriberta, model_afroxlmr_base, model_afrolm, za_lid, openlid, glotlid_3]
262
 
263
  my_bar = st.progress(0, text=progress_text)
264
 
@@ -270,8 +270,10 @@ def compute(sentences, version = 'v3'):
270
  for index, sent in enumerate(sentences):
271
  if type(model_choice) == list:
272
  all_models_pred = []
273
- for model in model_choice:
274
- if version not in ["openlid-201", "GlotLID v3"]:
 
 
275
  output = model.predict(sent)
276
  output_label = output[index]['label']
277
  output_prob = output[index]['score']
 
253
  model_choice = model_afrolm
254
  elif version == 'BERT':
255
  model_choice = za_lid
256
+ elif version == 'openlid-201':
257
  model_choice = openlid
258
  elif version == 'GlotLID v3':
259
  model_choice = glotlid_3
260
  else:
261
+ model_choice = [(model_xlmr_large, "xlmrlarge"),(model_serengeti,"serengeti"), (model_afriberta,"afriberta"), (model_afroxlmr_base,"afroxlmrbase"), (model_afrolm,"afrolm"), (za_lid,"BERT"), (openlid,"openlid-201"), (glotlid_3,"GlotLID v3")]
262
 
263
  my_bar = st.progress(0, text=progress_text)
264
 
 
270
  for index, sent in enumerate(sentences):
271
  if type(model_choice) == list:
272
  all_models_pred = []
273
+ for model_version in model_choice:
274
+ m_version = model_version[1]
275
+ model = model_version[0]
276
+ if m_version not in ["openlid-201", "GlotLID v3"]:
277
  output = model.predict(sent)
278
  output_label = output[index]['label']
279
  output_prob = output[index]['score']