nie3e commited on
Commit
2ab9a49
1 Parent(s): 890cc32

Initial commit

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipeline = pipeline(
5
+ task="text-classification",
6
+ model="nie3e/go-emotions-polish-gpt2-small-v0.0.1",
7
+ top_k=-1
8
+ )
9
+
10
+
11
+ def predict(text: str) -> dict:
12
+ predictions = pipeline(text)
13
+ return {p["label"]: p["score"] for p in predictions[0]}
14
+
15
+
16
+ app = gr.Interface(
17
+ predict,
18
+ inputs=gr.Textbox(label="Text"),
19
+ outputs=gr.Label(label="Emotions"),
20
+ title="Polish text emotions",
21
+ examples=[
22
+ "To jest model wykrywaj膮cy super emocje w tek艣cie! :D",
23
+ "Lato gor膮ce, pogodne, 偶贸艂te zbo偶e na polach, owies jeszcze zielony, "
24
+ "na 艂膮kach wielkie stogi pachn膮cego siana.",
25
+ "Sta艣 s艂ucha艂 z bij膮cym sercem i nat臋偶on膮 uwag膮.",
26
+ "Wyr贸偶nikiem, a tak偶e ciekawym elementem ca艂ego wystroju s膮 "
27
+ "umieszczone w centralnym miejscu rega艂y z ksi膮偶kami, tworz膮ce mini "
28
+ "bibliotek臋."
29
+ ]
30
+ )
31
+
32
+ if __name__ == "__main__":
33
+ app.launch()