Spaces:
Running
Running
prithivMLmods
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,24 @@ import torch
|
|
13 |
from diffusers import DiffusionPipeline
|
14 |
from typing import Tuple
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
style_list = [
|
18 |
{
|
@@ -131,7 +149,8 @@ def generate(
|
|
131 |
use_resolution_binning: bool = True,
|
132 |
progress=gr.Progress(track_tqdm=True),
|
133 |
):
|
134 |
-
|
|
|
135 |
|
136 |
prompt, negative_prompt = apply_style(style, prompt, negative_prompt)
|
137 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|
|
|
13 |
from diffusers import DiffusionPipeline
|
14 |
from typing import Tuple
|
15 |
|
16 |
+
#Check for the Model Base..//
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
bad_words = json.loads(os.getenv('BAD_WORDS', "[]"))
|
21 |
+
bad_words_negative = json.loads(os.getenv('BAD_WORDS_NEGATIVE', "[]"))
|
22 |
+
default_negative = os.getenv("default_negative","")
|
23 |
+
|
24 |
+
def check_text(prompt, negative=""):
|
25 |
+
for i in bad_words:
|
26 |
+
if i in prompt:
|
27 |
+
return True
|
28 |
+
for i in bad_words_negative:
|
29 |
+
if i in negative:
|
30 |
+
return True
|
31 |
+
return False
|
32 |
+
|
33 |
+
|
34 |
|
35 |
style_list = [
|
36 |
{
|
|
|
149 |
use_resolution_binning: bool = True,
|
150 |
progress=gr.Progress(track_tqdm=True),
|
151 |
):
|
152 |
+
if check_text(prompt, negative_prompt):
|
153 |
+
raise ValueError("Prompt contains restricted words.")
|
154 |
|
155 |
prompt, negative_prompt = apply_style(style, prompt, negative_prompt)
|
156 |
seed = int(randomize_seed_fn(seed, randomize_seed))
|