Spaces:
Runtime error
Runtime error
import gradio as gr | |
model_1 = gr.load("models/pimpilikipilapi1/NSFW_master") | |
model_2 = gr.load("models/DiegoJR1973/NSFW-TrioHMH-Flux") | |
model_3 = gr.load("models/prashanth970/flux-lora-uncensored") | |
default_negative_prompt = ( | |
"Extra limbs, Extra fingers or toes, Disfigured face, Distorted hands, Mutated body parts, " | |
"Missing limbs, Asymmetrical features, Blurry face, Poor anatomy, Incorrect proportions, Crooked eyes, " | |
"Deformed hands or fingers, Double face, Unrealistic skin texture, Overly smooth skin, Poor lighting, " | |
"Cartoonish appearance, Plastic look, Grainy, Unnatural expressions, Crossed eyes, Mutated clothing, " | |
"Artifacts, Uncanny valley, Doll-like features, Bad symmetry, Uneven skin tones, Extra teeth, " | |
"Unrealistic hair texture, Dark shadows on face, Overexposed face, Cluttered background, Text, watermark, " | |
"or signature, Over-processed, Low quality, Blurry, Low resolution, Pixelated, Oversaturated, Too dark, Overexposed, Poor lighting, " | |
"Unclear, Text or watermark, Distorted faces, Extra limbs or fingers, Disfigured, Grainy, Overly stylized, Cartoonish, " | |
"Unrealistic anatomy, Bad proportions, Unrealistic colors, Artificial look, Background noise, Unwanted objects, Repetitive patterns, Artifacting, Abstract shapes, Out of focus" | |
) | |
def process_image(model, prompt, negative_prompt=None, supports_negative_prompt=True): | |
try: | |
if "master" in str(model): | |
prompt += " 2k" | |
elif "Diego" in str(model): | |
prompt += " 8k" | |
else: | |
prompt += " 10k" | |
if supports_negative_prompt and negative_prompt: | |
return model(prompt, negative_prompt=negative_prompt) | |
else: | |
return model(prompt) | |
except TypeError: | |
return model(prompt) | |
def generate_images(prompt, negative_prompt): | |
output_1 = process_image(model_1, prompt, negative_prompt, True) | |
output_2 = process_image(model_2, prompt, negative_prompt, False) | |
output_3 = process_image(model_3, prompt, negative_prompt, True) | |
outputs = [] | |
for output in [output_1, output_2, output_3]: | |
if isinstance(output, tuple): | |
outputs.append(None) | |
else: | |
outputs.append(output) | |
return outputs | |
# Gradio Interface | |
interface = gr.Interface( | |
fn=generate_images, | |
inputs=[ | |
gr.Textbox(label="Type your prompt here: โ๏ธ", placeholder="Describe what you want..."), | |
gr.Textbox(label="Negative prompt:", value=default_negative_prompt), | |
], | |
outputs=[ | |
gr.Image(label="Generated Image - Model 1"), | |
gr.Image(label="Generated Image - Model 2"), | |
gr.Image(label="Generated Image - Model 3"), | |
], | |
title="Text to Image (NSFW) ๐", | |
theme="NoCrypt/miku", | |
description="โ ๏ธ Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.", | |
) | |
interface.launch(share=True) |