Julien Simon commited on
Commit
4938fc2
1 Parent(s): 0a6f20e

Initial version

Browse files
Files changed (2) hide show
  1. app.py +33 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ model_id = "juliensimon/xlm-v-base-language-id"
5
+
6
+ p = pipeline("text-classification", model=model_id)
7
+
8
+
9
+ def process(text, top_k=5):
10
+ pred = p(text, top_k=top_k)
11
+ scores = {x["label"]: x["score"] for x in pred}
12
+ print(scores)
13
+ return scores
14
+
15
+
16
+ # Gradio inputs
17
+ input_text = gr.Text(label="Enter text")
18
+
19
+ # Gradio outputs
20
+ labels = gr.Label(label="Languages", num_top_classes=5)
21
+
22
+ description = "This Space lets you perform language identification on the 102 languages present in the google/fleurs dataset."
23
+
24
+ iface = gr.Interface(
25
+ description=description,
26
+ fn=process,
27
+ inputs=input_text,
28
+ outputs=labels,
29
+ examples=[],
30
+ allow_flagging="never",
31
+ )
32
+
33
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch
2
+ transformers