Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ model_1 = gr.load("models/pimpilikipilapi1/NSFW_master")
|
|
| 5 |
model_2 = gr.load("models/DiegoJR1973/NSFW-TrioHMH-Flux")
|
| 6 |
model_3 = gr.load("models/prashanth970/flux-lora-uncensored")
|
| 7 |
|
|
|
|
| 8 |
default_negative_prompt = (
|
| 9 |
"Extra limbs, Extra fingers or toes, Disfigured face, Distorted hands, Mutated body parts, "
|
| 10 |
"Missing limbs, Asymmetrical features, Blurry face, Poor anatomy, Incorrect proportions, Crooked eyes, "
|
|
@@ -18,42 +19,33 @@ default_negative_prompt = (
|
|
| 18 |
)
|
| 19 |
|
| 20 |
|
| 21 |
-
def
|
|
|
|
| 22 |
try:
|
| 23 |
-
|
| 24 |
-
prompt += " 2k"
|
| 25 |
-
elif "Diego" in str(model):
|
| 26 |
-
prompt += " 8k"
|
| 27 |
-
else:
|
| 28 |
-
prompt += " 10k"
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
if supports_negative_prompt and negative_prompt:
|
| 32 |
-
return model(prompt, negative_prompt=negative_prompt)
|
| 33 |
-
else:
|
| 34 |
-
return model(prompt)
|
| 35 |
except TypeError:
|
| 36 |
-
return
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
def generate_images(prompt, negative_prompt):
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
if isinstance(output, tuple):
|
| 48 |
-
outputs.append(None)
|
| 49 |
-
else:
|
| 50 |
-
outputs.append(output)
|
| 51 |
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
# Gradio Interface
|
| 55 |
interface = gr.Interface(
|
| 56 |
-
fn=
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
inputs=[
|
| 58 |
gr.Textbox(label="Type your prompt here: ✍️", placeholder="Describe what you want..."),
|
| 59 |
gr.Textbox(label="Negative prompt:", value=default_negative_prompt),
|
|
@@ -68,4 +60,4 @@ interface = gr.Interface(
|
|
| 68 |
description="⚠️ Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
|
| 69 |
)
|
| 70 |
|
| 71 |
-
interface.launch(
|
|
|
|
| 5 |
model_2 = gr.load("models/DiegoJR1973/NSFW-TrioHMH-Flux")
|
| 6 |
model_3 = gr.load("models/prashanth970/flux-lora-uncensored")
|
| 7 |
|
| 8 |
+
|
| 9 |
default_negative_prompt = (
|
| 10 |
"Extra limbs, Extra fingers or toes, Disfigured face, Distorted hands, Mutated body parts, "
|
| 11 |
"Missing limbs, Asymmetrical features, Blurry face, Poor anatomy, Incorrect proportions, Crooked eyes, "
|
|
|
|
| 19 |
)
|
| 20 |
|
| 21 |
|
| 22 |
+
def generate_image_model_1(prompt, negative_prompt):
|
| 23 |
+
prompt += " 2k"
|
| 24 |
try:
|
| 25 |
+
return model_1(prompt, negative_prompt=negative_prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
except TypeError:
|
| 27 |
+
return model_1(prompt)
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
def generate_image_model_2(prompt, negative_prompt):
|
| 30 |
+
prompt += " 8k"
|
| 31 |
+
try:
|
| 32 |
+
return model_2(prompt, negative_prompt=negative_prompt)
|
| 33 |
+
except TypeError:
|
| 34 |
+
return model_2(prompt)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
def generate_image_model_3(prompt, negative_prompt):
|
| 37 |
+
prompt += " 10k"
|
| 38 |
+
try:
|
| 39 |
+
return model_3(prompt, negative_prompt=negative_prompt)
|
| 40 |
+
except TypeError:
|
| 41 |
+
return model_3(prompt)
|
| 42 |
|
|
|
|
| 43 |
interface = gr.Interface(
|
| 44 |
+
fn=lambda prompt, negative_prompt: (
|
| 45 |
+
generate_image_model_1(prompt, negative_prompt),
|
| 46 |
+
generate_image_model_2(prompt, negative_prompt),
|
| 47 |
+
generate_image_model_3(prompt, negative_prompt)
|
| 48 |
+
),
|
| 49 |
inputs=[
|
| 50 |
gr.Textbox(label="Type your prompt here: ✍️", placeholder="Describe what you want..."),
|
| 51 |
gr.Textbox(label="Negative prompt:", value=default_negative_prompt),
|
|
|
|
| 60 |
description="⚠️ Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
|
| 61 |
)
|
| 62 |
|
| 63 |
+
interface.launch()
|