Spaces:
Running
Running
deepkyu
commited on
Commit
·
31a0492
1
Parent(s):
6d97505
update return text format ( `1452164` in https://bitbucket.org/maum-system/cvpr22-demo-gradio )
Browse files
app.py
CHANGED
|
@@ -87,7 +87,7 @@ class GradioApplication:
|
|
| 87 |
|
| 88 |
@staticmethod
|
| 89 |
def return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=""):
|
| 90 |
-
return {'Toxicity': toxicity_prob}, f"Language: {lang_dest}\nText: {target_text}\nDetails: {detail}", str(video_filename)
|
| 91 |
|
| 92 |
def infer(self, text, lang, duration_rate, action, background_index):
|
| 93 |
self._counter_file_seed()
|
|
@@ -105,7 +105,7 @@ class GradioApplication:
|
|
| 105 |
|
| 106 |
if toxicity_prob > TOXICITY_THRESHOLD:
|
| 107 |
detail = "Sorry, it seems that the input text is too toxic."
|
| 108 |
-
return self.return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=detail)
|
| 109 |
|
| 110 |
# Google Translate API
|
| 111 |
try:
|
|
@@ -114,12 +114,12 @@ class GradioApplication:
|
|
| 114 |
target_text = ""
|
| 115 |
lang_dest = ""
|
| 116 |
detail = f"Error from language translation: ({e})"
|
| 117 |
-
return self.return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=detail)
|
| 118 |
|
| 119 |
try:
|
| 120 |
self.translator.length_check(lang_dest, target_text) # assertion check
|
| 121 |
except AssertionError as e:
|
| 122 |
-
return self.return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=str(e))
|
| 123 |
|
| 124 |
lang_rpc_code = self.get_lang_code(lang_dest)
|
| 125 |
|
|
|
|
| 87 |
|
| 88 |
@staticmethod
|
| 89 |
def return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=""):
|
| 90 |
+
return {'Toxicity': toxicity_prob}, f"Language: {lang_dest}\nText: {target_text}\n-\nDetails: {detail}", str(video_filename)
|
| 91 |
|
| 92 |
def infer(self, text, lang, duration_rate, action, background_index):
|
| 93 |
self._counter_file_seed()
|
|
|
|
| 105 |
|
| 106 |
if toxicity_prob > TOXICITY_THRESHOLD:
|
| 107 |
detail = "Sorry, it seems that the input text is too toxic."
|
| 108 |
+
return self.return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=f"Error: {detail}")
|
| 109 |
|
| 110 |
# Google Translate API
|
| 111 |
try:
|
|
|
|
| 114 |
target_text = ""
|
| 115 |
lang_dest = ""
|
| 116 |
detail = f"Error from language translation: ({e})"
|
| 117 |
+
return self.return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=f"Error: {detail}")
|
| 118 |
|
| 119 |
try:
|
| 120 |
self.translator.length_check(lang_dest, target_text) # assertion check
|
| 121 |
except AssertionError as e:
|
| 122 |
+
return self.return_format(toxicity_prob, target_text, lang_dest, video_filename, detail=f"Error: {str(e)}")
|
| 123 |
|
| 124 |
lang_rpc_code = self.get_lang_code(lang_dest)
|
| 125 |
|