Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
-
|
|
|
|
|
4 |
import torch
|
5 |
from transformers import pipeline
|
6 |
from transformers import M2M100Tokenizer, M2M100ForConditionalGeneration
|
@@ -12,7 +14,7 @@ model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin")
|
|
12 |
identification_model = fasttext.load_model(model_path)
|
13 |
def lang_ident(text):
|
14 |
label, array = identification_model.predict(text)
|
15 |
-
label = get_name(label[0])
|
16 |
return {language : label[0], socore : array[0]}
|
17 |
|
18 |
pretrained_model: str = "facebook/m2m100_1.2B"
|
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
+
import os
|
4 |
+
import string
|
5 |
+
import re
|
6 |
import torch
|
7 |
from transformers import pipeline
|
8 |
from transformers import M2M100Tokenizer, M2M100ForConditionalGeneration
|
|
|
14 |
identification_model = fasttext.load_model(model_path)
|
15 |
def lang_ident(text):
|
16 |
label, array = identification_model.predict(text)
|
17 |
+
label = get_name(label[0].split('__')[-1].replace('_Hans', '_Hani').replace('_Hant', '_Hani'))
|
18 |
return {language : label[0], socore : array[0]}
|
19 |
|
20 |
pretrained_model: str = "facebook/m2m100_1.2B"
|