Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -23,15 +23,7 @@ nli_example = [["Bunu çok beğendim. Bunu çok sevdim."]]
|
|
23 |
|
24 |
|
25 |
t2t_gen_model = pipeline(model="boun-tabi-LMG/TURNA", device=0)
|
26 |
-
|
27 |
-
summarization_model = pipeline(model="boun-tabi-LMG/turna_summarization_mlsum", device=0)
|
28 |
-
# examples =long_text, title="Summarization", description="TURNA fine-tuned on MLSUM. Enter a text to summarize below.")
|
29 |
-
news_sum = pipeline(model="boun-tabi-LMG/turna_summarization_tr_news", device=0)
|
30 |
-
# examples =long_text, title="News Summarization", description="TURNA fine-tuned on News summarization. Enter a news to summarize.")
|
31 |
-
paraphrasing = pipeline(model="boun-tabi-LMG/turna_paraphrasing_tatoeba", device=0)
|
32 |
-
# examples =long_text,title="Paraphrasing")
|
33 |
-
paraphrasing_sub = pipeline(model="boun-tabi-LMG/turna_paraphrasing_opensubtitles", device=0)
|
34 |
-
# examples =long_text, title="Paraphrasing on Subtitles")
|
35 |
|
36 |
ttc = pipeline(model="boun-tabi-LMG/turna_classification_ttc4900", device=0)
|
37 |
# examples =long_text, title="Text Categorization")
|
@@ -42,18 +34,11 @@ title_gen = pipeline(model="boun-tabi-LMG/turna_title_generation_mlsum", device=
|
|
42 |
sentiment_model = pipeline(model="boun-tabi-LMG/turna_classification_17bintweet_sentiment", device=0)
|
43 |
#examples=sentiment_example, title="Sentiment Analysis", description="Enter a text to generate title to.")
|
44 |
|
45 |
-
|
46 |
-
# title="Part of Speech Tagging", examples=ner_example,description="Enter a text to generate title to.")
|
47 |
nli_model = pipeline(model="boun-tabi-LMG/turna_nli_nli_tr", device=0)
|
48 |
-
|
49 |
-
pos_boun = pipeline(model="boun-tabi-LMG/turna_pos_boun", device=0)
|
50 |
-
# examples = ner_example, title="Part of Speech Tagging", description="Enter a text to tag parts of speech (POS).")
|
51 |
stsb_model = pipeline(model="boun-tabi-LMG/turna_semantic_similarity_stsb_tr", device=0)
|
52 |
-
|
53 |
-
ner_model = pipeline(model="boun-tabi-LMG/turna_ner_milliyet", device=0)
|
54 |
-
# title="NER WikiANN", examples=ner_example, description="Enter a text for NER.")
|
55 |
-
ner_wikiann = pipeline(model="boun-tabi-LMG/turna_ner_wikiann", device=0)
|
56 |
-
#title="NER",examples=ner_example, description="Enter a text for NER.")
|
57 |
|
58 |
|
59 |
@spaces.GPU
|
@@ -75,15 +60,19 @@ def t2t(input):
|
|
75 |
return t2t_gen_model(input)
|
76 |
|
77 |
@spaces.GPU
|
78 |
-
def pos(input,
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
return pos_imst(input)
|
|
|
|
|
83 |
|
84 |
@spaces.GPU
|
85 |
-
def ner(input,
|
86 |
-
|
|
|
|
|
87 |
return ner_wikiann(input)
|
88 |
else:
|
89 |
return ner_model(input)
|
@@ -91,6 +80,8 @@ def ner(input, wikiann=True):
|
|
91 |
|
92 |
@spaces.GPU
|
93 |
def paraphrase(input, model_choice="turna_paraphrasing_tatoeba"):
|
|
|
|
|
94 |
if model_choice=="turna_paraphrasing_tatoeba":
|
95 |
return paraphrasing(input)
|
96 |
else:
|
@@ -98,6 +89,8 @@ def paraphrase(input, model_choice="turna_paraphrasing_tatoeba"):
|
|
98 |
|
99 |
@spaces.GPU
|
100 |
def summarize(input, model_choice="turna_summarization_tr_news"):
|
|
|
|
|
101 |
if model_choice=="turna_summarization_tr_news":
|
102 |
return news_sum(input)
|
103 |
else:
|
@@ -108,8 +101,39 @@ def summarize(input, model_choice="turna_summarization_tr_news"):
|
|
108 |
with gr.Blocks(theme="shivi/calm_seafoam") as demo:
|
109 |
gr.Markdown("# TURNA 🐦")
|
110 |
gr.Markdown(DESCRIPTION)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
with gr.Tab("Summarization"):
|
112 |
-
gr.Markdown("TURNA fine-tuned on
|
113 |
with gr.Column():
|
114 |
with gr.Row():
|
115 |
sum_choice = gr.Radio(choices = ["turna_summarization_mlsum", "turna_summarization_tr_news"])
|
@@ -117,5 +141,5 @@ with gr.Blocks(theme="shivi/calm_seafoam") as demo:
|
|
117 |
sum_output = gr.Text()
|
118 |
sum_submit = gr.Button()
|
119 |
sum_submit.click(summarize, inputs=[sum_input, sum_choice], outputs=sum_output)
|
120 |
-
|
121 |
demo.launch()
|
|
|
23 |
|
24 |
|
25 |
t2t_gen_model = pipeline(model="boun-tabi-LMG/TURNA", device=0)
|
26 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
ttc = pipeline(model="boun-tabi-LMG/turna_classification_ttc4900", device=0)
|
29 |
# examples =long_text, title="Text Categorization")
|
|
|
34 |
sentiment_model = pipeline(model="boun-tabi-LMG/turna_classification_17bintweet_sentiment", device=0)
|
35 |
#examples=sentiment_example, title="Sentiment Analysis", description="Enter a text to generate title to.")
|
36 |
|
37 |
+
|
|
|
38 |
nli_model = pipeline(model="boun-tabi-LMG/turna_nli_nli_tr", device=0)
|
39 |
+
|
|
|
|
|
40 |
stsb_model = pipeline(model="boun-tabi-LMG/turna_semantic_similarity_stsb_tr", device=0)
|
41 |
+
|
|
|
|
|
|
|
|
|
42 |
|
43 |
|
44 |
@spaces.GPU
|
|
|
60 |
return t2t_gen_model(input)
|
61 |
|
62 |
@spaces.GPU
|
63 |
+
def pos(input, model_choice="turna_pos_imst"):
|
64 |
+
pos_imst = pipeline(model="boun-tabi-LMG/turna_pos_imst", device=0)
|
65 |
+
pos_boun = pipeline(model="boun-tabi-LMG/turna_pos_boun", device=0)
|
66 |
+
if model_choice=="turna_pos_imst":
|
67 |
return pos_imst(input)
|
68 |
+
else:
|
69 |
+
return pos_boun(input)
|
70 |
|
71 |
@spaces.GPU
|
72 |
+
def ner(input, model_choice="turna_ner_wikiann"):
|
73 |
+
ner_model = pipeline(model="boun-tabi-LMG/turna_ner_milliyet", device=0)
|
74 |
+
ner_wikiann = pipeline(model="boun-tabi-LMG/turna_ner_wikiann", device=0)
|
75 |
+
if model_choice=="turna_ner_wikiann":
|
76 |
return ner_wikiann(input)
|
77 |
else:
|
78 |
return ner_model(input)
|
|
|
80 |
|
81 |
@spaces.GPU
|
82 |
def paraphrase(input, model_choice="turna_paraphrasing_tatoeba"):
|
83 |
+
paraphrasing = pipeline(model="boun-tabi-LMG/turna_paraphrasing_tatoeba", device=0)
|
84 |
+
paraphrasing_sub = pipeline(model="boun-tabi-LMG/turna_paraphrasing_opensubtitles", device=0)
|
85 |
if model_choice=="turna_paraphrasing_tatoeba":
|
86 |
return paraphrasing(input)
|
87 |
else:
|
|
|
89 |
|
90 |
@spaces.GPU
|
91 |
def summarize(input, model_choice="turna_summarization_tr_news"):
|
92 |
+
summarization_model = pipeline(model="boun-tabi-LMG/turna_summarization_mlsum", device=0)
|
93 |
+
news_sum = pipeline(model="boun-tabi-LMG/turna_summarization_tr_news", device=0)
|
94 |
if model_choice=="turna_summarization_tr_news":
|
95 |
return news_sum(input)
|
96 |
else:
|
|
|
101 |
with gr.Blocks(theme="shivi/calm_seafoam") as demo:
|
102 |
gr.Markdown("# TURNA 🐦")
|
103 |
gr.Markdown(DESCRIPTION)
|
104 |
+
with gr.Tab("POS"):
|
105 |
+
gr.Markdown("TURNA fine-tuned on part-of-speech-tagging. Enter text to parse parts of speech and pick the model.")
|
106 |
+
with gr.Column():
|
107 |
+
with gr.Row():
|
108 |
+
pos_choice = gr.Radio(choices = ["turna_pos_imst", "turna_pos_boun"])
|
109 |
+
pos_input = gr.Text()
|
110 |
+
pos_output = gr.Text()
|
111 |
+
pos_submit = gr.Button()
|
112 |
+
pos_submit.click(pos, inputs=[pos_input, pos_choice], outputs=pos_output)
|
113 |
+
pos_examples = gr.Examples(examples = ner_example, inputs = [pos_input, pos_choice], outputs=pos_output, fn=pos)
|
114 |
+
|
115 |
+
with gr.Tab("NER"):
|
116 |
+
gr.Markdown("TURNA fine-tuned on named entity recognition. Enter text to parse named entities and pick the model.")
|
117 |
+
with gr.Column():
|
118 |
+
with gr.Row():
|
119 |
+
ner_choice = gr.Radio(choices = ["turna_ner_wikiann", "turna_ner_milliyet"])
|
120 |
+
ner_input = gr.Text()
|
121 |
+
ner_output = gr.Text()
|
122 |
+
ner_submit = gr.Button()
|
123 |
+
ner_submit.click(ner, inputs=[ner_input, ner_choice], outputs=ner_output)
|
124 |
+
ner_examples = gr.Examples(examples = ner_example, inputs = [ner_input, ner_choice], outputs=ner_output, fn=ner)
|
125 |
+
with gr.Tab("Paraphrase"):
|
126 |
+
gr.Markdown("TURNA fine-tuned on paraphrasing. Enter text to paraphrase and pick the model.")
|
127 |
+
with gr.Column():
|
128 |
+
with gr.Row():
|
129 |
+
paraphrasing_choice = gr.Radio(choices = ["turna_paraphrasing_tatoeba", "turna_paraphrasing_opensubtitles"])
|
130 |
+
paraphrasing_input = gr.Text()
|
131 |
+
paraphrasing_output = gr.Text()
|
132 |
+
paraphrasing_submit = gr.Button()
|
133 |
+
paraphrasing_submit.click(paraphrase, inputs=[paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output)
|
134 |
+
paraphrase_examples = gr.Examples(examples = long_text, inputs = [paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output, fn=paraphrase)
|
135 |
with gr.Tab("Summarization"):
|
136 |
+
gr.Markdown("TURNA fine-tuned on summarization. Enter text to summarize and pick the model.")
|
137 |
with gr.Column():
|
138 |
with gr.Row():
|
139 |
sum_choice = gr.Radio(choices = ["turna_summarization_mlsum", "turna_summarization_tr_news"])
|
|
|
141 |
sum_output = gr.Text()
|
142 |
sum_submit = gr.Button()
|
143 |
sum_submit.click(summarize, inputs=[sum_input, sum_choice], outputs=sum_output)
|
144 |
+
sum_examples = gr.Examples(examples = long_text, inputs = [sum_input, sum_choice], outputs=sum_output, fn=summarize)
|
145 |
demo.launch()
|