Spaces:
Runtime error
Runtime error
dinalzein
commited on
Commit
Β·
dfb0587
1
Parent(s):
409b791
try diff method
Browse files
app.py
CHANGED
@@ -33,6 +33,12 @@ def identify_language(txt):
|
|
33 |
return languages_map[id2label[str(y_pred[0])]]
|
34 |
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
#with gr.Row():
|
38 |
examples = [
|
@@ -72,7 +78,7 @@ article = ('''## Suppoted Langauges \n
|
|
72 |
|
73 |
|
74 |
gr.Interface(
|
75 |
-
fn=
|
76 |
inputs=inputs,
|
77 |
outputs=outputs,
|
78 |
verbose=True,
|
|
|
33 |
return languages_map[id2label[str(y_pred[0])]]
|
34 |
|
35 |
|
36 |
+
def identify_language2(txt):
|
37 |
+
tokenized_txt = tokenizer(txt, return_tensors='pt')
|
38 |
+
output = model(**tokenized_txt)
|
39 |
+
predictions = torch.nn.functional.softmax(output.logits, dim=-1)
|
40 |
+
_, preds = torch.max(predictions, dim=-1)
|
41 |
+
return languages_map[id2labe[str(preds.item())]]
|
42 |
|
43 |
#with gr.Row():
|
44 |
examples = [
|
|
|
78 |
|
79 |
|
80 |
gr.Interface(
|
81 |
+
fn=identify_language2,
|
82 |
inputs=inputs,
|
83 |
outputs=outputs,
|
84 |
verbose=True,
|