Jonny001 commited on
Commit
0aad51a
·
verified ·
1 Parent(s): 0862982

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -31
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 process_image(model, prompt, negative_prompt=None, supports_negative_prompt=True):
 
22
  try:
23
- if "master" in str(model):
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 model(prompt)
37
-
38
-
39
- def generate_images(prompt, negative_prompt):
40
 
41
- output_1 = process_image(model_1, prompt, negative_prompt, True)
42
- output_2 = process_image(model_2, prompt, negative_prompt, False)
43
- output_3 = process_image(model_3, prompt, negative_prompt, True)
44
-
45
- outputs = []
46
- for output in [output_1, output_2, output_3]:
47
- if isinstance(output, tuple):
48
- outputs.append(None)
49
- else:
50
- outputs.append(output)
51
 
52
- return outputs
 
 
 
 
 
53
 
54
- # Gradio Interface
55
  interface = gr.Interface(
56
- fn=generate_images,
 
 
 
 
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(share=True)
 
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()