Preparing for presentation
Browse files
app.py
CHANGED
|
@@ -6,7 +6,9 @@ import gradio as gr
|
|
| 6 |
|
| 7 |
hf_token = os.getenv("HF_TOKEN")
|
| 8 |
model_id = int(os.getenv("Model"))
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
#stable-diffusion-xl-base-1.0 0 - base model
|
| 12 |
#Colossus_Project_XL 1 - better people
|
|
@@ -21,9 +23,6 @@ model_url_list = ["stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_base
|
|
| 21 |
"SG161222/RealVisXL_V2.0/blob/main/RealVisXL_V2.0.safetensors",
|
| 22 |
"Krebzonide/AcornIsSpinning_acornXLV1/blob/main/acornIsSpinning_acornxlV1.safetensors"]
|
| 23 |
|
| 24 |
-
naughtyWords = ["nude", "nsfw", "naked", "porn", "boob", "tit", "nipple", "vagina", "pussy", "panties", "underwear", "upskirt", "bottomless", "topless", "petite", "xxx"]
|
| 25 |
-
|
| 26 |
-
|
| 27 |
css = """
|
| 28 |
.btn-green {
|
| 29 |
background-image: linear-gradient(to bottom right, #6dd178, #00a613) !important;
|
|
@@ -37,12 +36,12 @@ css = """
|
|
| 37 |
|
| 38 |
def generate(prompt, neg_prompt, samp_steps, cfg_scale, batch_size, seed, height, width, progress=gr.Progress(track_tqdm=True)):
|
| 39 |
prompt = prompt.lower()
|
| 40 |
-
if
|
| 41 |
-
if prompt[:
|
| 42 |
-
prompt = prompt[
|
| 43 |
else:
|
| 44 |
-
neg_prompt = neg_prompt + ", child, nsfw,
|
| 45 |
-
for word in
|
| 46 |
if prompt.find(word) >= 0:
|
| 47 |
return None, 58008
|
| 48 |
if seed < 0:
|
|
@@ -90,11 +89,7 @@ examples = [
|
|
| 90 |
['cinematic photo of a woman sitting at a cafe, 35mm photograph, film, bokeh, professional, 4k, detailed face',
|
| 91 |
'drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly'],
|
| 92 |
['analog film photo of old woman on the streets of london, faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage',
|
| 93 |
-
'painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured']
|
| 94 |
-
#['nude photo of a 20 year old model in the back seat of a car, detailed face',
|
| 95 |
-
#'big boobs'],
|
| 96 |
-
#['nude photo of a 20 year old man, penis and testicles, dick and balls, erection',
|
| 97 |
-
#'woman']
|
| 98 |
]
|
| 99 |
|
| 100 |
with gr.Blocks(css=css) as demo:
|
|
|
|
| 6 |
|
| 7 |
hf_token = os.getenv("HF_TOKEN")
|
| 8 |
model_id = int(os.getenv("Model"))
|
| 9 |
+
nsfw_filter_enabled = int(os.getenv("Safe"))
|
| 10 |
+
naughty_words = os.getenv("NaughtyWords").split()
|
| 11 |
+
override = os.getenv("Override")
|
| 12 |
|
| 13 |
#stable-diffusion-xl-base-1.0 0 - base model
|
| 14 |
#Colossus_Project_XL 1 - better people
|
|
|
|
| 23 |
"SG161222/RealVisXL_V2.0/blob/main/RealVisXL_V2.0.safetensors",
|
| 24 |
"Krebzonide/AcornIsSpinning_acornXLV1/blob/main/acornIsSpinning_acornxlV1.safetensors"]
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
css = """
|
| 27 |
.btn-green {
|
| 28 |
background-image: linear-gradient(to bottom right, #6dd178, #00a613) !important;
|
|
|
|
| 36 |
|
| 37 |
def generate(prompt, neg_prompt, samp_steps, cfg_scale, batch_size, seed, height, width, progress=gr.Progress(track_tqdm=True)):
|
| 38 |
prompt = prompt.lower()
|
| 39 |
+
if nsfw_filter_enabled:
|
| 40 |
+
if prompt[:len(override)] == override:
|
| 41 |
+
prompt = prompt[len(override):]
|
| 42 |
else:
|
| 43 |
+
neg_prompt = neg_prompt + ", child, nsfw, nude, underwear"
|
| 44 |
+
for word in naughty_words:
|
| 45 |
if prompt.find(word) >= 0:
|
| 46 |
return None, 58008
|
| 47 |
if seed < 0:
|
|
|
|
| 89 |
['cinematic photo of a woman sitting at a cafe, 35mm photograph, film, bokeh, professional, 4k, detailed face',
|
| 90 |
'drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly'],
|
| 91 |
['analog film photo of old woman on the streets of london, faded film, desaturated, 35mm photo, grainy, vignette, vintage, Kodachrome, Lomography, stained, highly detailed, found footage',
|
| 92 |
+
'painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured']
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
]
|
| 94 |
|
| 95 |
with gr.Blocks(css=css) as demo:
|