ddosxd commited on
Commit
0a7de84
1 Parent(s): d487ab5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -6
app.py CHANGED
@@ -13,13 +13,16 @@ import torch
13
  from diffusers import DiffusionPipeline
14
 
15
  bad_words = json.loads(os.getenv('BAD_WORDS', "[]"))
 
 
16
 
17
- #print(bad_words)
18
-
19
- def check_text(prompt):
20
  for i in bad_words:
21
  if i in prompt:
22
  return True
 
 
 
23
  return False
24
 
25
  DESCRIPTION = """# RealVisXL_V3.0"""
@@ -77,7 +80,7 @@ def generate(prompt: str,
77
  randomize_seed: bool = False,
78
  use_resolution_binning: bool = True,
79
  progress=gr.Progress(track_tqdm=True)):
80
- if check_text(prompt):
81
  return 'NSFW Detection'
82
  return _generate(
83
  prompt,
@@ -110,8 +113,8 @@ def _generate(
110
  generator = torch.Generator().manual_seed(seed)
111
 
112
  if not use_negative_prompt:
113
- negative_prompt = None # type: ignore
114
-
115
  images = pipe(
116
  prompt=prompt,
117
  negative_prompt=negative_prompt,
 
13
  from diffusers import DiffusionPipeline
14
 
15
  bad_words = json.loads(os.getenv('BAD_WORDS', "[]"))
16
+ bad_words_negative = json.loads(os.getenv('BAD_WORDS_NEGATIVE', "[]"))
17
+ default_negative = os.getenv("default_negative","")
18
 
19
+ def check_text(prompt, negative=""):
 
 
20
  for i in bad_words:
21
  if i in prompt:
22
  return True
23
+ for i in bad_words_negative:
24
+ if i in negative:
25
+ return True
26
  return False
27
 
28
  DESCRIPTION = """# RealVisXL_V3.0"""
 
80
  randomize_seed: bool = False,
81
  use_resolution_binning: bool = True,
82
  progress=gr.Progress(track_tqdm=True)):
83
+ if check_text(prompt, negative_prompt):
84
  return 'NSFW Detection'
85
  return _generate(
86
  prompt,
 
113
  generator = torch.Generator().manual_seed(seed)
114
 
115
  if not use_negative_prompt:
116
+ negative_prompt = "" # type: ignore
117
+ negative_prompt += default_negative
118
  images = pipe(
119
  prompt=prompt,
120
  negative_prompt=negative_prompt,