Update app.py
Browse files
app.py
CHANGED
@@ -55,16 +55,16 @@ def get_response(input_text):
|
|
55 |
#num_beam_groups=num_beams, diversity_penalty=0.5
|
56 |
tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
|
57 |
try:
|
58 |
-
|
59 |
-
if len(
|
60 |
-
|
61 |
-
if len(
|
62 |
-
diversity_scored_phrases = diversity_score.rank(input_text,
|
63 |
-
return get_max_str(
|
64 |
else:
|
65 |
-
return get_max_str(
|
66 |
else:
|
67 |
-
return get_max_str(
|
68 |
except:
|
69 |
return(get_max_str(tgt_text))
|
70 |
|
@@ -72,8 +72,8 @@ def get_response(input_text):
|
|
72 |
|
73 |
import gradio as gr
|
74 |
|
75 |
-
def get_fun(
|
76 |
-
tokens = splitter.split(text=
|
77 |
|
78 |
txt_paraphrase=''
|
79 |
for phrase in tokens:
|
@@ -81,7 +81,7 @@ def get_fun(txt):
|
|
81 |
txt_paraphrase=txt_paraphrase+' '+tmp
|
82 |
return txt_paraphrase
|
83 |
|
84 |
-
iface = gr.Interface(fn=get_fun, inputs="text", outputs="text", title = " Ai Re-Phraser Q'Hackday")
|
85 |
iface.launch(inline=False)
|
86 |
|
87 |
"""# New Section"""
|
|
|
55 |
#num_beam_groups=num_beams, diversity_penalty=0.5
|
56 |
tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
|
57 |
try:
|
58 |
+
adequacy_filtered = adequacy_score.filter(input_text,tgt_text, adequacy_threshold, device)
|
59 |
+
if len(adequacy_filtered) > 0 :
|
60 |
+
fluency_filtered_ = fluency_score.filter(adequacy_filtered, fluency_threshold, device )
|
61 |
+
if len(fluency_filtered) > 0 :
|
62 |
+
diversity_scored_phrases = diversity_score.rank(input_text, fluency_filtered, diversity_ranker)
|
63 |
+
return get_max_str(diversity_scored)
|
64 |
else:
|
65 |
+
return get_max_str(fluency_filtered)
|
66 |
else:
|
67 |
+
return get_max_str(adequacy_filtered)
|
68 |
except:
|
69 |
return(get_max_str(tgt_text))
|
70 |
|
|
|
72 |
|
73 |
import gradio as gr
|
74 |
|
75 |
+
def get_fun(Input_txt):
|
76 |
+
tokens = splitter.split(text=Input_txt)
|
77 |
|
78 |
txt_paraphrase=''
|
79 |
for phrase in tokens:
|
|
|
81 |
txt_paraphrase=txt_paraphrase+' '+tmp
|
82 |
return txt_paraphrase
|
83 |
|
84 |
+
iface = gr.Interface(fn=get_fun, inputs="text", outputs="text" (lines=5), title = " Ai Re-Phraser Q'Hackday")
|
85 |
iface.launch(inline=False)
|
86 |
|
87 |
"""# New Section"""
|