Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -34,9 +34,9 @@ def nli(input, model_choice="turna_nli_nli_tr"):
|
|
34 |
stsb_model = pipeline(model="boun-tabi-LMG/turna_semantic_similarity_stsb_tr", device=0)
|
35 |
|
36 |
if model_choice=="turna_nli_nli_tr":
|
37 |
-
return nli_model(input)
|
38 |
else:
|
39 |
-
return stsb_model(input)
|
40 |
|
41 |
@spaces.GPU
|
42 |
def nli(input, model_choice="turna_nli_nli_tr"):
|
@@ -44,47 +44,40 @@ def nli(input, model_choice="turna_nli_nli_tr"):
|
|
44 |
stsb_model = pipeline(model="boun-tabi-LMG/turna_semantic_similarity_stsb_tr", device=0)
|
45 |
|
46 |
if model_choice=="turna_nli_nli_tr":
|
47 |
-
return nli_model(input)
|
48 |
else:
|
49 |
-
return stsb_model(input)
|
50 |
|
51 |
@spaces.GPU
|
52 |
def sentiment_analysis(input, model_choice="turna_classification_17bintweet_sentiment"):
|
53 |
product_reviews = pipeline(model="boun-tabi-LMG/turna_classification_tr_product_reviews", device=0)
|
54 |
sentiment_model = pipeline(model="boun-tabi-LMG/turna_classification_17bintweet_sentiment", device=0)
|
55 |
if model_choice=="turna_classification_17bintweet_sentiment":
|
56 |
-
return sentiment_model(input)
|
57 |
else:
|
58 |
-
return product_reviews(input)
|
59 |
-
|
60 |
-
@spaces.GPU
|
61 |
-
def nli_stsb(input, nli=True):
|
62 |
-
if nli==True:
|
63 |
-
return nli_model(input)
|
64 |
-
else:
|
65 |
-
return stsb_model(input)
|
66 |
|
67 |
@spaces.GPU
|
68 |
def t2t(input):
|
69 |
return t2t_gen_model(input)
|
70 |
|
71 |
@spaces.GPU
|
72 |
-
def pos(input, model_choice="turna_pos_imst"):
|
73 |
-
pos_imst = pipeline(model="boun-tabi-LMG/turna_pos_imst", device=0)
|
74 |
-
pos_boun = pipeline(model="boun-tabi-LMG/turna_pos_boun", device=0)
|
75 |
if model_choice=="turna_pos_imst":
|
76 |
-
|
|
|
77 |
else:
|
78 |
-
|
|
|
79 |
|
80 |
@spaces.GPU
|
81 |
def ner(input, model_choice="turna_ner_wikiann"):
|
82 |
-
ner_model = pipeline(model="boun-tabi-LMG/turna_ner_milliyet", device=0)
|
83 |
-
ner_wikiann = pipeline(model="boun-tabi-LMG/turna_ner_wikiann", device=0)
|
84 |
if model_choice=="turna_ner_wikiann":
|
85 |
-
|
|
|
86 |
else:
|
87 |
-
|
|
|
88 |
|
89 |
|
90 |
@spaces.GPU
|
@@ -92,18 +85,18 @@ def paraphrase(input, model_choice="turna_paraphrasing_tatoeba"):
|
|
92 |
paraphrasing = pipeline(model="boun-tabi-LMG/turna_paraphrasing_tatoeba", device=0)
|
93 |
paraphrasing_sub = pipeline(model="boun-tabi-LMG/turna_paraphrasing_opensubtitles", device=0)
|
94 |
if model_choice=="turna_paraphrasing_tatoeba":
|
95 |
-
return paraphrasing(input)
|
96 |
else:
|
97 |
-
return paraphrasing_sub(input)
|
98 |
|
99 |
@spaces.GPU
|
100 |
def summarize(input, model_choice="turna_summarization_tr_news"):
|
101 |
summarization_model = pipeline(model="boun-tabi-LMG/turna_summarization_mlsum", device=0)
|
102 |
news_sum = pipeline(model="boun-tabi-LMG/turna_summarization_tr_news", device=0)
|
103 |
if model_choice=="turna_summarization_tr_news":
|
104 |
-
return news_sum(input)
|
105 |
else:
|
106 |
-
return summarization_model(input)
|
107 |
|
108 |
|
109 |
|
@@ -127,8 +120,9 @@ with gr.Blocks(theme="soft") as demo:
|
|
127 |
with gr.Row():
|
128 |
ner_choice = gr.Radio(choices = ["turna_ner_wikiann", "turna_ner_milliyet"], label ="Model")
|
129 |
ner_input = gr.Textbox(label="NER Input")
|
130 |
-
ner_output = gr.Textbox(label="NER Output")
|
131 |
ner_submit = gr.Button()
|
|
|
|
|
132 |
ner_submit.click(ner, inputs=[ner_input, ner_choice], outputs=ner_output)
|
133 |
ner_examples = gr.Examples(examples = ner_example, inputs = [ner_input, ner_choice], outputs=ner_output, fn=ner)
|
134 |
with gr.Tab("Paraphrase"):
|
@@ -137,8 +131,9 @@ with gr.Blocks(theme="soft") as demo:
|
|
137 |
with gr.Row():
|
138 |
paraphrasing_choice = gr.Radio(choices = ["turna_paraphrasing_tatoeba", "turna_paraphrasing_opensubtitles"], label ="Model")
|
139 |
paraphrasing_input = gr.Textbox(label = "Paraphrasing Input")
|
140 |
-
paraphrasing_output = gr.Text(label="Paraphrasing Output")
|
141 |
paraphrasing_submit = gr.Button()
|
|
|
|
|
142 |
paraphrasing_submit.click(paraphrase, inputs=[paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output)
|
143 |
paraphrase_examples = gr.Examples(examples = long_text, inputs = [paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output, fn=paraphrase)
|
144 |
with gr.Tab("Summarization"):
|
@@ -147,8 +142,9 @@ with gr.Blocks(theme="soft") as demo:
|
|
147 |
with gr.Row():
|
148 |
sum_choice = gr.Radio(choices = ["turna_summarization_mlsum", "turna_summarization_tr_news"], label ="Model")
|
149 |
sum_input = gr.Textbox(label = "Summarization Input")
|
150 |
-
sum_output = gr.Textbox(label = "Summarization Output")
|
151 |
sum_submit = gr.Button()
|
|
|
|
|
152 |
sum_submit.click(summarize, inputs=[sum_input, sum_choice], outputs=sum_output)
|
153 |
sum_examples = gr.Examples(examples = long_text, inputs = [sum_input, sum_choice], outputs=sum_output, fn=summarize)
|
154 |
demo.launch()
|
|
|
34 |
stsb_model = pipeline(model="boun-tabi-LMG/turna_semantic_similarity_stsb_tr", device=0)
|
35 |
|
36 |
if model_choice=="turna_nli_nli_tr":
|
37 |
+
return nli_model(input)[0]["generated_text"]
|
38 |
else:
|
39 |
+
return stsb_model(input)[0]["generated_text"]
|
40 |
|
41 |
@spaces.GPU
|
42 |
def nli(input, model_choice="turna_nli_nli_tr"):
|
|
|
44 |
stsb_model = pipeline(model="boun-tabi-LMG/turna_semantic_similarity_stsb_tr", device=0)
|
45 |
|
46 |
if model_choice=="turna_nli_nli_tr":
|
47 |
+
return nli_model(input)[0]["generated_text"]
|
48 |
else:
|
49 |
+
return stsb_model(input)[0]["generated_text"]
|
50 |
|
51 |
@spaces.GPU
|
52 |
def sentiment_analysis(input, model_choice="turna_classification_17bintweet_sentiment"):
|
53 |
product_reviews = pipeline(model="boun-tabi-LMG/turna_classification_tr_product_reviews", device=0)
|
54 |
sentiment_model = pipeline(model="boun-tabi-LMG/turna_classification_17bintweet_sentiment", device=0)
|
55 |
if model_choice=="turna_classification_17bintweet_sentiment":
|
56 |
+
return sentiment_model(input)[0]["generated_text"]
|
57 |
else:
|
58 |
+
return product_reviews(input)[0]["generated_text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
@spaces.GPU
|
61 |
def t2t(input):
|
62 |
return t2t_gen_model(input)
|
63 |
|
64 |
@spaces.GPU
|
65 |
+
def pos(input, model_choice="turna_pos_imst"):
|
|
|
|
|
66 |
if model_choice=="turna_pos_imst":
|
67 |
+
pos_imst = pipeline(model="boun-tabi-LMG/turna_pos_imst", device=0)
|
68 |
+
return pos_imst(input)[0]["generated_text"]
|
69 |
else:
|
70 |
+
pos_boun = pipeline(model="boun-tabi-LMG/turna_pos_boun", device=0)
|
71 |
+
return pos_boun(input)[0]["generated_text"]
|
72 |
|
73 |
@spaces.GPU
|
74 |
def ner(input, model_choice="turna_ner_wikiann"):
|
|
|
|
|
75 |
if model_choice=="turna_ner_wikiann":
|
76 |
+
ner_wikiann = pipeline(model="boun-tabi-LMG/turna_ner_wikiann", device=0)
|
77 |
+
return ner_wikiann(input)[0]["generated_text"]
|
78 |
else:
|
79 |
+
ner_model = pipeline(model="boun-tabi-LMG/turna_ner_milliyet", device=0)
|
80 |
+
return ner_model(input)[0]["generated_text"]
|
81 |
|
82 |
|
83 |
@spaces.GPU
|
|
|
85 |
paraphrasing = pipeline(model="boun-tabi-LMG/turna_paraphrasing_tatoeba", device=0)
|
86 |
paraphrasing_sub = pipeline(model="boun-tabi-LMG/turna_paraphrasing_opensubtitles", device=0)
|
87 |
if model_choice=="turna_paraphrasing_tatoeba":
|
88 |
+
return paraphrasing(input)[0]["generated_text"]
|
89 |
else:
|
90 |
+
return paraphrasing_sub(input)[0]["generated_text"]
|
91 |
|
92 |
@spaces.GPU
|
93 |
def summarize(input, model_choice="turna_summarization_tr_news"):
|
94 |
summarization_model = pipeline(model="boun-tabi-LMG/turna_summarization_mlsum", device=0)
|
95 |
news_sum = pipeline(model="boun-tabi-LMG/turna_summarization_tr_news", device=0)
|
96 |
if model_choice=="turna_summarization_tr_news":
|
97 |
+
return news_sum(input)[0]["generated_text"]
|
98 |
else:
|
99 |
+
return summarization_model(input)[0]["generated_text"]
|
100 |
|
101 |
|
102 |
|
|
|
120 |
with gr.Row():
|
121 |
ner_choice = gr.Radio(choices = ["turna_ner_wikiann", "turna_ner_milliyet"], label ="Model")
|
122 |
ner_input = gr.Textbox(label="NER Input")
|
|
|
123 |
ner_submit = gr.Button()
|
124 |
+
ner_output = gr.Textbox(label="NER Output")
|
125 |
+
|
126 |
ner_submit.click(ner, inputs=[ner_input, ner_choice], outputs=ner_output)
|
127 |
ner_examples = gr.Examples(examples = ner_example, inputs = [ner_input, ner_choice], outputs=ner_output, fn=ner)
|
128 |
with gr.Tab("Paraphrase"):
|
|
|
131 |
with gr.Row():
|
132 |
paraphrasing_choice = gr.Radio(choices = ["turna_paraphrasing_tatoeba", "turna_paraphrasing_opensubtitles"], label ="Model")
|
133 |
paraphrasing_input = gr.Textbox(label = "Paraphrasing Input")
|
|
|
134 |
paraphrasing_submit = gr.Button()
|
135 |
+
paraphrasing_output = gr.Text(label="Paraphrasing Output")
|
136 |
+
|
137 |
paraphrasing_submit.click(paraphrase, inputs=[paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output)
|
138 |
paraphrase_examples = gr.Examples(examples = long_text, inputs = [paraphrasing_input, paraphrasing_choice], outputs=paraphrasing_output, fn=paraphrase)
|
139 |
with gr.Tab("Summarization"):
|
|
|
142 |
with gr.Row():
|
143 |
sum_choice = gr.Radio(choices = ["turna_summarization_mlsum", "turna_summarization_tr_news"], label ="Model")
|
144 |
sum_input = gr.Textbox(label = "Summarization Input")
|
|
|
145 |
sum_submit = gr.Button()
|
146 |
+
sum_output = gr.Textbox(label = "Summarization Output")
|
147 |
+
|
148 |
sum_submit.click(summarize, inputs=[sum_input, sum_choice], outputs=sum_output)
|
149 |
sum_examples = gr.Examples(examples = long_text, inputs = [sum_input, sum_choice], outputs=sum_output, fn=summarize)
|
150 |
demo.launch()
|