Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Speedup process by skipping toxicity check of Harvard sentences
Browse files
app.py
CHANGED
@@ -543,7 +543,11 @@ def synthandreturn(text):
|
|
543 |
raise gr.Error(f'You exceeded the limit of {MAX_SAMPLE_TXT_LENGTH} characters')
|
544 |
if len(text) < MIN_SAMPLE_TXT_LENGTH:
|
545 |
raise gr.Error(f'Please input a text longer than {MIN_SAMPLE_TXT_LENGTH} characters')
|
546 |
-
if (
|
|
|
|
|
|
|
|
|
547 |
print(f'Detected toxic content! "{text}"')
|
548 |
raise gr.Error('Your text failed the toxicity test')
|
549 |
if not text:
|
|
|
543 |
raise gr.Error(f'You exceeded the limit of {MAX_SAMPLE_TXT_LENGTH} characters')
|
544 |
if len(text) < MIN_SAMPLE_TXT_LENGTH:
|
545 |
raise gr.Error(f'Please input a text longer than {MIN_SAMPLE_TXT_LENGTH} characters')
|
546 |
+
if (
|
547 |
+
# test toxicity if not prepared text
|
548 |
+
text not in sents
|
549 |
+
and toxicity.predict(text)['toxicity'] > 0.8
|
550 |
+
):
|
551 |
print(f'Detected toxic content! "{text}"')
|
552 |
raise gr.Error('Your text failed the toxicity test')
|
553 |
if not text:
|