ChenoAi commited on
Commit
9b6e90b
1 Parent(s): 771c2a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +77 -8
app.py CHANGED
@@ -23,7 +23,68 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
23
 
24
  MAX_SEED = np.iinfo(np.int32).max
25
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
 
 
 
 
 
27
 
28
  JX_pipe = StableDiffusionXLPipeline.from_pretrained(
29
  "RunDiffusion/Juggernaut-X-Hyper",
@@ -55,6 +116,7 @@ J9_pipe.to("cuda")
55
  @spaces.GPU
56
  def run_comparison(prompt: str,
57
  negative_prompt: str = "",
 
58
  use_negative_prompt: bool = False,
59
  num_inference_steps: int = 30,
60
  num_images_per_prompt: int = 2,
@@ -119,16 +181,23 @@ with gr.Blocks(theme=gr.themes.Base()) as demo:
119
  gr.Markdown('Compare Juggernaut-XL variants and distillations able to generate images in a single diffusion step')
120
  prompt = gr.Textbox(label="Prompt")
121
  run = gr.Button("Run")
 
 
 
 
 
 
 
 
 
122
  with gr.Accordion("Advanced options", open=False):
123
- use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True)
124
  negative_prompt = gr.Text(
125
- label="Negative prompt",
126
- lines=4,
127
- max_lines=6,
128
- value="""(deformed, distorted, disfigured:1.3), poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, (mutated hands and fingers:1.4), disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, (NSFW:1.25)""",
129
- placeholder="Enter a negative prompt",
130
- visible=True,
131
- )
132
  with gr.Row():
133
  num_inference_steps = gr.Slider(
134
  label="Steps",
 
23
 
24
  MAX_SEED = np.iinfo(np.int32).max
25
  vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
26
+ # by PixArt-alpha/PixArt-Sigma
27
+ style_list = [
28
+ {
29
+ "name": "(No style)",
30
+ "prompt": "{prompt}",
31
+ "negative_prompt": "",
32
+ },
33
+ {
34
+ "name": "Cinematic",
35
+ "prompt": "cinematic still {prompt} . emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy",
36
+ "negative_prompt": "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured",
37
+ },
38
+ {
39
+ "name": "Photographic",
40
+ "prompt": "cinematic photo {prompt} . 35mm photograph, film, bokeh, professional, 4k, highly detailed",
41
+ "negative_prompt": "drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly",
42
+ },
43
+ {
44
+ "name": "Anime",
45
+ "prompt": "anime artwork {prompt} . anime style, key visual, vibrant, studio anime, highly detailed",
46
+ "negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast",
47
+ },
48
+ {
49
+ "name": "Manga",
50
+ "prompt": "manga style {prompt} . vibrant, high-energy, detailed, iconic, Japanese comic style",
51
+ "negative_prompt": "ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, Western comic style",
52
+ },
53
+ {
54
+ "name": "Digital Art",
55
+ "prompt": "concept art {prompt} . digital artwork, illustrative, painterly, matte painting, highly detailed",
56
+ "negative_prompt": "photo, photorealistic, realism, ugly",
57
+ },
58
+ {
59
+ "name": "Pixel art",
60
+ "prompt": "pixel-art {prompt} . low-res, blocky, pixel art style, 8-bit graphics",
61
+ "negative_prompt": "sloppy, messy, blurry, noisy, highly detailed, ultra textured, photo, realistic",
62
+ },
63
+ {
64
+ "name": "Fantasy art",
65
+ "prompt": "ethereal fantasy concept art of {prompt} . magnificent, celestial, ethereal, painterly, epic, majestic, magical, fantasy art, cover art, dreamy",
66
+ "negative_prompt": "photographic, realistic, realism, 35mm film, dslr, cropped, frame, text, deformed, glitch, noise, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, sloppy, duplicate, mutated, black and white",
67
+ },
68
+ {
69
+ "name": "Neonpunk",
70
+ "prompt": "neonpunk style {prompt} . cyberpunk, vaporwave, neon, vibes, vibrant, stunningly beautiful, crisp, detailed, sleek, ultramodern, magenta highlights, dark purple shadows, high contrast, cinematic, ultra detailed, intricate, professional",
71
+ "negative_prompt": "painting, drawing, illustration, glitch, deformed, mutated, cross-eyed, ugly, disfigured",
72
+ },
73
+ {
74
+ "name": "3D Model",
75
+ "prompt": "professional 3d model {prompt} . octane render, highly detailed, volumetric, dramatic lighting",
76
+ "negative_prompt": "ugly, deformed, noisy, low poly, blurry, painting",
77
+ },
78
+ ]
79
+ styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
80
+ STYLE_NAMES = list(styles.keys())
81
+ DEFAULT_STYLE_NAME = "(No style)"
82
 
83
+ def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
84
+ p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
85
+ if not negative:
86
+ negative = ""
87
+ return p.replace("{prompt}", positive), n + negative
88
 
89
  JX_pipe = StableDiffusionXLPipeline.from_pretrained(
90
  "RunDiffusion/Juggernaut-X-Hyper",
 
116
  @spaces.GPU
117
  def run_comparison(prompt: str,
118
  negative_prompt: str = "",
119
+ style: str = DEFAULT_STYLE_NAME,
120
  use_negative_prompt: bool = False,
121
  num_inference_steps: int = 30,
122
  num_images_per_prompt: int = 2,
 
181
  gr.Markdown('Compare Juggernaut-XL variants and distillations able to generate images in a single diffusion step')
182
  prompt = gr.Textbox(label="Prompt")
183
  run = gr.Button("Run")
184
+ with gr.Row(visible=True):
185
+ style_selection = gr.Radio(
186
+ show_label=True,
187
+ container=True,
188
+ interactive=True,
189
+ choices=STYLE_NAMES,
190
+ value=DEFAULT_STYLE_NAME,
191
+ label="Image Style",
192
+ )
193
  with gr.Accordion("Advanced options", open=False):
194
+ use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=False, visible=True)
195
  negative_prompt = gr.Text(
196
+ label="Negative prompt",
197
+ max_lines=1,
198
+ placeholder="Enter a negative prompt",
199
+ visible=True,
200
+ )
 
 
201
  with gr.Row():
202
  num_inference_steps = gr.Slider(
203
  label="Steps",