dancrvlh commited on
Commit
5213f0f
·
1 Parent(s): 18e83fd

Creating Hugging face aplication

Browse files
Files changed (2) hide show
  1. app.py +35 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
3
+ import torch
4
+
5
+ model_name = "dancrvlh/Language"
6
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
7
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+
9
+ mapping = {
10
+ 2:"English",
11
+ 3:"French",
12
+ 4:"Portugeese",
13
+ 5:"Russian",
14
+ 6:"Sweedish",
15
+ 7:"unknow"
16
+ }
17
+
18
+ def predict(text):
19
+ inputs = tokenizer(text, return_tensors="pt")
20
+
21
+ outputs = model(**inputs)
22
+ predictions = outputs.logits
23
+
24
+ return mapping[round(predictions.item())]
25
+
26
+ iface = gr.Interface(
27
+ fn=predict,
28
+ inputs="text",
29
+ outputs="text",
30
+ layout="vertical",
31
+ title="Language Detection",
32
+ description="This model can detect the language your text for English, French, Portugeese, Russian, Sweedish and Unknow",
33
+ )
34
+
35
+ iface.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformes
3
+ torch