Jonny001 commited on
Commit
baf2123
1 Parent(s): 5198cff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -27
app.py CHANGED
@@ -2,6 +2,9 @@ import gradio as gr
2
  import random
3
  import os
4
 
 
 
 
5
 
6
  default_negative_prompt = (
7
  "Extra limbs, Extra fingers or toes, Disfigured face, Distorted hands, Mutated body parts, "
@@ -15,18 +18,17 @@ default_negative_prompt = (
15
  "Unrealistic anatomy, Bad proportions, Unrealistic colors, Artificial look, Background noise, Unwanted objects, Repetitive patterns, Artifacting, Abstract shapes, Out of focus"
16
  )
17
 
18
- model = gr.load("models/Purz/face-projection")
19
-
20
- def generate_image(text, seed, width, height, guidance_scale, num_inference_steps, negative_prompt):
21
  if seed is not None:
22
  random.seed(seed)
23
 
24
  if text in [example[0] for example in examples]:
25
  print(f"Using example: {text}")
26
 
 
27
  result_image = model(text, negative_prompt=negative_prompt)
28
 
29
- print(f"Width: {width}, Height: {height}, Guidance Scale: {guidance_scale}, Inference Steps: {num_inference_steps}, Negative Prompt: {negative_prompt}")
30
 
31
  return result_image
32
 
@@ -55,15 +57,6 @@ interface = gr.Interface(
55
  gr.Slider(label="Height", minimum=512, maximum=2048, step=64, value=1024),
56
  gr.Slider(label="Guidance Scale", minimum=0.1, maximum=20.0, step=0.1, value=3.0),
57
  gr.Slider(label="Number of inference steps", minimum=1, maximum=40, step=1, value=28),
58
- gr.Dropdown(
59
- label="Negative Prompt",
60
- choices=[
61
- "Default Negative Prompt",
62
- "None",
63
- ],
64
- value="Default Negative Prompt",
65
- description="Choose a negative prompt to apply to the image generation."
66
- ),
67
  ],
68
  outputs=gr.Image(label="Generated Image"),
69
  examples=examples,
@@ -71,17 +64,4 @@ interface = gr.Interface(
71
  description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
72
  )
73
 
74
- def get_negative_prompt(negative_prompt_choice):
75
- if negative_prompt_choice == "Default Negative Prompt":
76
- return default_negative_prompt
77
- else:
78
- return ""
79
-
80
-
81
- def generate_image_with_negative_prompt(text, seed, width, height, guidance_scale, num_inference_steps, negative_prompt_choice):
82
- negative_prompt = get_negative_prompt(negative_prompt_choice)
83
- return generate_image(text, seed, width, height, guidance_scale, num_inference_steps, negative_prompt)
84
-
85
- interface.fn = generate_image_with_negative_prompt
86
-
87
- interface.launch()
 
2
  import random
3
  import os
4
 
5
+ # model = gr.load("models/prithivMLmods/SD3.5-Turbo-Realism-2.0-LoRA") # <-- This model is also working
6
+ model = gr.load("models/Purz/face-projection")
7
+
8
 
9
  default_negative_prompt = (
10
  "Extra limbs, Extra fingers or toes, Disfigured face, Distorted hands, Mutated body parts, "
 
18
  "Unrealistic anatomy, Bad proportions, Unrealistic colors, Artificial look, Background noise, Unwanted objects, Repetitive patterns, Artifacting, Abstract shapes, Out of focus"
19
  )
20
 
21
+ def generate_image(text, seed, width, height, guidance_scale, num_inference_steps, negative_prompt=default_negative_prompt):
 
 
22
  if seed is not None:
23
  random.seed(seed)
24
 
25
  if text in [example[0] for example in examples]:
26
  print(f"Using example: {text}")
27
 
28
+
29
  result_image = model(text, negative_prompt=negative_prompt)
30
 
31
+ print(f"Width: {width}, Height: {height}, Guidance Scale: {guidance_scale}, Inference Steps: {num_inference_steps}")
32
 
33
  return result_image
34
 
 
57
  gr.Slider(label="Height", minimum=512, maximum=2048, step=64, value=1024),
58
  gr.Slider(label="Guidance Scale", minimum=0.1, maximum=20.0, step=0.1, value=3.0),
59
  gr.Slider(label="Number of inference steps", minimum=1, maximum=40, step=1, value=28),
 
 
 
 
 
 
 
 
 
60
  ],
61
  outputs=gr.Image(label="Generated Image"),
62
  examples=examples,
 
64
  description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
65
  )
66
 
67
+ interface.launch()