mrfakename Pendrokar commited on
Commit
bda9f8b
1 Parent(s): 0408757

Speedup process by skipping toxicity check of Harvard sentences (#32)

Browse files

- Speedup process by skipping toxicity check of Harvard sentences (d44b4f7d057a5f7df52c1ea7cdceb12453c24c62)


Co-authored-by: Yanis L <Pendrokar@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +5 -1
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 (toxicity.predict(text)['toxicity'] > 0.8):
 
 
 
 
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: