FilipeR commited on
Commit
6cc6c1f
1 Parent(s): 5995c77

Revert 4084703..HEAD.

Browse files
Files changed (3) hide show
  1. README.md +9 -12
  2. app.py +88 -220
  3. requirements.txt +3 -7
README.md CHANGED
@@ -1,20 +1,17 @@
1
  ---
2
- header: mini
3
- title: CloneJourney
4
- short_description: Copy of prithivMLmods/Midjourney; reverts ad9f8e^..df49a2e.
5
- colorFrom: indigo
6
- colorTo: indigo
7
- emoji: 🦏🦏
8
- pinned: true
9
  sdk: gradio
10
  sdk_version: 4.36.1
11
- theme: rawrsor1/Everforest
12
  app_file: app.py
 
 
 
13
  license: creativeml-openrail-m
14
- disable_embedding: true
15
- model: SG161222/RealVisXL_V4.0
16
- preload_from_hub:
17
- - SG161222/RealVisXL_V4.0
18
  ---
19
 
20
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: MIDJOURNEY
3
+ emoji: 🏜️
4
+ colorFrom: green
5
+ colorTo: purple
 
 
 
6
  sdk: gradio
7
  sdk_version: 4.36.1
 
8
  app_file: app.py
9
+ pinned: true
10
+ header: mini
11
+ model: RealVisXL_Turbo
12
  license: creativeml-openrail-m
13
+ theme: bethecloud/storj_theme
14
+ short_description: MidJour | A RealVisXL_Turbo | IRL HI-Res Images Gen
 
 
15
  ---
16
 
17
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -1,4 +1,5 @@
1
  #!/usr/bin/env python
 
2
  import os
3
  import random
4
  import uuid
@@ -12,7 +13,10 @@ import torch
12
  from diffusers import DiffusionPipeline
13
  from typing import Tuple
14
 
15
- #BaseConditions--
 
 
 
16
  bad_words = json.loads(os.getenv('BAD_WORDS', "[]"))
17
  bad_words_negative = json.loads(os.getenv('BAD_WORDS_NEGATIVE', "[]"))
18
  default_negative = os.getenv("default_negative","")
@@ -26,12 +30,10 @@ def check_text(prompt, negative=""):
26
  return True
27
  return False
28
 
 
 
29
  style_list = [
30
- {
31
- "name": "3840 x 2160",
32
- "prompt": "hyper-realistic 8K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic",
33
- "negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, deformed, ugly",
34
- },
35
  {
36
  "name": "2560 x 1440",
37
  "prompt": "hyper-realistic 4K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic",
@@ -39,172 +41,102 @@ style_list = [
39
  },
40
 
41
  {
42
- "name": "HD+",
43
- "prompt": "hyper-realistic 2K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic",
44
- "negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, deformed, ugly",
45
- },
46
-
47
- {
48
- "name": "Style Zero",
49
- "prompt": "{prompt}",
50
- "negative_prompt": "",
51
- },
52
- ]
53
 
54
- collage_style_list = [
55
- {
56
- "name": "Hi-Res",
57
- "prompt": "hyper-realistic 8K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic",
58
- "negative_prompt": "cartoonish, low resolution, blurry, simplistic, abstract, deformed, ugly",
59
- },
60
- {
61
- "name": "B & W",
62
- "prompt": "black and white collage of {prompt}. monochromatic, timeless, classic, dramatic contrast",
63
- "negative_prompt": "colorful, vibrant, bright, flashy",
64
- },
65
- {
66
- "name": "Polaroid",
67
- "prompt": "collage of polaroid photos featuring {prompt}. vintage style, high contrast, nostalgic, instant film aesthetic",
68
- "negative_prompt": "digital, modern, low quality, blurry",
69
- },
70
- {
71
- "name": "Watercolor",
72
- "prompt": "watercolor collage of {prompt}. soft edges, translucent colors, painterly effects",
73
- "negative_prompt": "digital, sharp lines, solid colors",
74
- },
75
  {
76
  "name": "Cinematic",
77
- "prompt": "cinematic collage of {prompt}. film stills, movie posters, dramatic lighting",
78
- "negative_prompt": "static, lifeless, mundane",
79
- },
80
- {
81
- "name": "Nostalgic",
82
- "prompt": "nostalgic collage of {prompt}. retro imagery, vintage objects, sentimental journey",
83
- "negative_prompt": "contemporary, futuristic, forward-looking",
84
- },
85
- {
86
- "name": "Vintage",
87
- "prompt": "vintage collage of {prompt}. aged paper, sepia tones, retro imagery, antique vibes",
88
- "negative_prompt": "modern, contemporary, futuristic, high-tech",
89
- },
90
- {
91
- "name": "Scrapbook",
92
- "prompt": "scrapbook style collage of {prompt}. mixed media, hand-cut elements, textures, paper, stickers, doodles",
93
- "negative_prompt": "clean, digital, modern, low quality",
94
- },
95
- {
96
- "name": "NeoNGlow",
97
- "prompt": "neon glow collage of {prompt}. vibrant colors, glowing effects, futuristic vibes",
98
- "negative_prompt": "dull, muted colors, vintage, retro",
99
  },
 
100
  {
101
- "name": "Geometric",
102
- "prompt": "geometric collage of {prompt}. abstract shapes, colorful, sharp edges, modern design, high quality",
103
- "negative_prompt": "blurry, low quality, traditional, dull",
104
  },
105
  {
106
- "name": "Thematic",
107
- "prompt": "thematic collage of {prompt}. cohesive theme, well-organized, matching colors, creative layout",
108
- "negative_prompt": "random, messy, unorganized, clashing colors",
109
  },
110
-
111
  {
112
- "name": "No Style",
113
  "prompt": "{prompt}",
114
  "negative_prompt": "",
115
  },
116
  ]
117
 
118
- filters = {
119
- "Vivid": {
120
- "prompt": "extra vivid {prompt}",
121
- "negative_prompt": "washed out, dull"
122
- },
123
- "Playa": {
124
- "prompt": "{prompt} set in a vast playa",
125
- "negative_prompt": "forest, mountains"
126
- },
127
- "Desert": {
128
- "prompt": "{prompt} set in a desert landscape",
129
- "negative_prompt": "ocean, city"
130
- },
131
- "West": {
132
- "prompt": "{prompt} with a western theme",
133
- "negative_prompt": "eastern, modern"
134
- },
135
- "Blush": {
136
- "prompt": "{prompt} with a soft blush color palette",
137
- "negative_prompt": "harsh colors, neon"
138
- },
139
- "Minimalist": {
140
- "prompt": "{prompt} with a minimalist design",
141
- "negative_prompt": "cluttered, ornate"
142
- },
143
-
144
- "Zero filter": {
145
- "prompt": "{prompt}",
146
- "negative_prompt": ""
147
- },
148
-
149
-
150
- }
151
-
152
  styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
153
- collage_styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in collage_style_list}
154
- filter_styles = {k: (v["prompt"], v["negative_prompt"]) for k, v in filters.items()}
155
  STYLE_NAMES = list(styles.keys())
156
- COLLAGE_STYLE_NAMES = list(collage_styles.keys())
157
- FILTER_NAMES = list(filters.keys())
158
- DEFAULT_STYLE_NAME = "3840 x 2160"
159
- DEFAULT_COLLAGE_STYLE_NAME = "Hi-Res"
160
- DEFAULT_FILTER_NAME = "Vivid"
161
 
162
  def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
163
- if style_name in styles:
164
- p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
165
- elif style_name in collage_styles:
166
- p, n = collage_styles.get(style_name, collage_styles[DEFAULT_COLLAGE_STYLE_NAME])
167
- elif style_name in filter_styles:
168
- p, n = filter_styles.get(style_name, filter_styles[DEFAULT_FILTER_NAME])
169
- else:
170
- p, n = styles[DEFAULT_STYLE_NAME]
171
-
172
  if not negative:
173
  negative = ""
174
  return p.replace("{prompt}", positive), n + negative
175
 
 
 
176
 
177
 
178
- DESCRIPTION = """## CloneJourney
 
 
179
  """
180
 
 
 
 
 
 
 
 
181
  MAX_SEED = np.iinfo(np.int32).max
182
- CACHE_EXAMPLES = torch.cuda.is_available() and os.getenv("CACHE_EXAMPLES", "lazy")
183
  MAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "2048"))
184
- USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE", "1") == "1"
185
- ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "1") == "1"
186
 
187
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
188
 
 
 
189
  if torch.cuda.is_available():
190
  pipe = DiffusionPipeline.from_pretrained(
191
- "SG161222/RealVisXL_V4.0",
192
  torch_dtype=torch.float16,
193
  use_safetensors=True,
194
  add_watermarker=False,
195
  variant="fp16"
196
- ).to(device)
197
-
 
 
 
 
 
 
198
  if ENABLE_CPU_OFFLOAD:
199
  pipe.enable_model_cpu_offload()
 
200
  else:
201
- pipe.to(device)
202
-
 
 
203
  if USE_TORCH_COMPILE:
204
- pipe.unet = torch.compile(pipe.unet, mode="max-autotune", fullgraph=True)
 
 
205
 
206
- def save_image(img, path):
207
- img.save(path)
 
 
208
 
209
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
210
  if randomize_seed:
@@ -217,12 +149,9 @@ def generate(
217
  negative_prompt: str = "",
218
  use_negative_prompt: bool = False,
219
  style: str = DEFAULT_STYLE_NAME,
220
- collage_style: str = DEFAULT_COLLAGE_STYLE_NAME,
221
- filter_name: str = DEFAULT_FILTER_NAME,
222
- grid_size: str = "2x2",
223
  seed: int = 0,
224
- width: int = 896,
225
- height: int = 1152,
226
  guidance_scale: float = 3,
227
  randomize_seed: bool = False,
228
  use_resolution_binning: bool = True,
@@ -231,13 +160,7 @@ def generate(
231
  if check_text(prompt, negative_prompt):
232
  raise ValueError("Prompt contains restricted words.")
233
 
234
- if collage_style != "No Style":
235
- prompt, negative_prompt = apply_style(collage_style, prompt, negative_prompt)
236
- elif filter_name != "No Filter":
237
- prompt, negative_prompt = apply_style(filter_name, prompt, negative_prompt)
238
- else:
239
- prompt, negative_prompt = apply_style(style, prompt, negative_prompt)
240
-
241
  seed = int(randomize_seed_fn(seed, randomize_seed))
242
  generator = torch.Generator().manual_seed(seed)
243
 
@@ -245,52 +168,33 @@ def generate(
245
  negative_prompt = "" # type: ignore
246
  negative_prompt += default_negative
247
 
248
- grid_sizes = {
249
- "2x1": (2, 1),
250
- "1x2": (1, 2),
251
- "2x2": (2, 2),
252
- "2x3": (2, 3),
253
- "3x2": (3, 2),
254
- "1x1": (1, 1)
255
- }
256
-
257
- grid_size_x, grid_size_y = grid_sizes.get(grid_size, (2, 2))
258
- num_images = grid_size_x * grid_size_y
259
-
260
  options = {
261
  "prompt": prompt,
262
  "negative_prompt": negative_prompt,
263
  "width": width,
264
  "height": height,
265
  "guidance_scale": guidance_scale,
266
- "num_inference_steps": 20,
267
  "generator": generator,
268
- "num_images_per_prompt": num_images,
269
  "use_resolution_binning": use_resolution_binning,
270
  "output_type": "pil",
271
  }
272
 
273
- torch.cuda.empty_cache() # Clear GPU memory
274
- images = pipe(**options).images
275
-
276
- grid_img = Image.new('RGB', (width * grid_size_x, height * grid_size_y))
277
 
278
- for i, img in enumerate(images[:num_images]):
279
- grid_img.paste(img, (i % grid_size_x * width, i // grid_size_x * height))
280
-
281
- unique_name = str(uuid.uuid4()) + ".png"
282
- save_image(grid_img, unique_name)
283
- return [unique_name], seed
284
 
285
  examples = [
286
- "Portrait of a beautiful woman in a hat, summer outfit, with freckles on her face, in a close up shot, with sunlight, outdoors, in soft light, with a beach background, looking at the camera, with high resolution photography, in the style of Hasselblad X2D50c --ar 85:128 --v 6.0 --style raw",
287
- "3d image, cute girl, in the style of Pixar --ar 1:2 --stylize 750, 4K resolution highlights, Sharp focus, octane render, ray tracing, Ultra-High-Definition, 8k, UHD, HDR, (Masterpiece:1.5), (best quality:1.5)",
288
- "Cold coffee in a cup bokeh --ar 85:128 --v 6.0 --style raw5, 4K, Photo-Realistic",
289
  "Closeup of blonde woman depth of field, bokeh, shallow focus, minimalism, fujifilm xh2s with Canon EF lens, cinematic --ar 85:128 --v 6.0 --style raw"
290
  ]
291
 
292
  css = '''
293
- .gradio-container{max-width: 670px !important}
294
  h1{text-align:center}
295
  '''
296
  with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
@@ -310,61 +214,23 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
310
  container=False,
311
  )
312
  run_button = gr.Button("Run")
313
- result = gr.Gallery(label="Grid", columns=1, preview=True)
314
-
315
-
316
- with gr.Row(visible=True):
317
- filter_selection = gr.Radio(
318
- show_label=True,
319
- container=True,
320
- interactive=True,
321
- choices=FILTER_NAMES,
322
- value=DEFAULT_FILTER_NAME,
323
- label="Filter Type",
324
- )
325
-
326
- with gr.Row(visible=True):
327
- style_selection = gr.Radio(
328
- show_label=True,
329
- container=True,
330
- interactive=True,
331
- choices=STYLE_NAMES,
332
- value=DEFAULT_STYLE_NAME,
333
- label="Quality Style",
334
- )
335
-
336
- with gr.Row(visible=True):
337
- collage_style_selection = gr.Radio(
338
- show_label=True,
339
- container=True,
340
- interactive=True,
341
- choices=COLLAGE_STYLE_NAMES,
342
- value=DEFAULT_COLLAGE_STYLE_NAME,
343
- label="Collage Template",
344
- )
345
- with gr.Row(visible=True):
346
- grid_size_selection = gr.Dropdown(
347
- choices=["2x1", "1x2", "2x2", "2x3", "3x2", "1x1"],
348
- value="2x2",
349
- label="Grid Size"
350
- )
351
-
352
  with gr.Accordion("Advanced options", open=False):
353
  use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True, visible=True)
354
  negative_prompt = gr.Text(
355
  label="Negative prompt",
356
  max_lines=1,
357
  placeholder="Enter a negative prompt",
358
- 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",
359
  visible=True,
360
  )
361
  with gr.Row():
362
  num_inference_steps = gr.Slider(
363
  label="Steps",
364
  minimum=10,
365
- maximum=30,
366
  step=1,
367
- value=15,
368
  )
369
  with gr.Row():
370
  num_images_per_prompt = gr.Slider(
@@ -383,7 +249,6 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
383
  visible=True
384
  )
385
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
386
-
387
  with gr.Row(visible=True):
388
  width = gr.Slider(
389
  label="Width",
@@ -399,7 +264,6 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
399
  step=8,
400
  value=1024,
401
  )
402
-
403
  with gr.Row():
404
  guidance_scale = gr.Slider(
405
  label="Guidance Scale",
@@ -408,13 +272,20 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
408
  step=0.1,
409
  value=6,
410
  )
411
-
 
 
 
 
 
 
 
 
412
  gr.Examples(
413
  examples=examples,
414
  inputs=prompt,
415
  outputs=[result, seed],
416
  fn=generate,
417
- #cache_examples=True,
418
  cache_examples=CACHE_EXAMPLES,
419
  )
420
 
@@ -437,9 +308,6 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
437
  negative_prompt,
438
  use_negative_prompt,
439
  style_selection,
440
- collage_style_selection,
441
- filter_selection,
442
- grid_size_selection,
443
  seed,
444
  width,
445
  height,
@@ -451,4 +319,4 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
451
  )
452
 
453
  if __name__ == "__main__":
454
- demo.queue(max_size=20).launch()
 
1
  #!/usr/bin/env python
2
+
3
  import os
4
  import random
5
  import uuid
 
13
  from diffusers import DiffusionPipeline
14
  from typing import Tuple
15
 
16
+ #Check for the Model Base..//
17
+
18
+
19
+
20
  bad_words = json.loads(os.getenv('BAD_WORDS', "[]"))
21
  bad_words_negative = json.loads(os.getenv('BAD_WORDS_NEGATIVE', "[]"))
22
  default_negative = os.getenv("default_negative","")
 
30
  return True
31
  return False
32
 
33
+
34
+
35
  style_list = [
36
+
 
 
 
 
37
  {
38
  "name": "2560 x 1440",
39
  "prompt": "hyper-realistic 4K image of {prompt}. ultra-detailed, lifelike, high-resolution, sharp, vibrant colors, photorealistic",
 
41
  },
42
 
43
  {
44
+ "name": "Photo",
45
+ "prompt": "cinematic photo {prompt}. 35mm photograph, film, bokeh, professional, 4k, highly detailed",
46
+ "negative_prompt": "drawing, painting, crayon, sketch, graphite, impressionist, noisy, blurry, soft, deformed, ugly",
47
+ },
 
 
 
 
 
 
 
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  {
50
  "name": "Cinematic",
51
+ "prompt": "cinematic still {prompt}. emotional, harmonious, vignette, highly detailed, high budget, bokeh, cinemascope, moody, epic, gorgeous, film grain, grainy",
52
+ "negative_prompt": "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  },
54
+
55
  {
56
+ "name": "Anime",
57
+ "prompt": "anime artwork {prompt}. anime style, key visual, vibrant, studio anime, highly detailed",
58
+ "negative_prompt": "photo, deformed, black and white, realism, disfigured, low contrast",
59
  },
60
  {
61
+ "name": "3D Model",
62
+ "prompt": "professional 3d model {prompt}. octane render, highly detailed, volumetric, dramatic lighting",
63
+ "negative_prompt": "ugly, deformed, noisy, low poly, blurry, painting",
64
  },
 
65
  {
66
+ "name": "(No style)",
67
  "prompt": "{prompt}",
68
  "negative_prompt": "",
69
  },
70
  ]
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
 
 
73
  STYLE_NAMES = list(styles.keys())
74
+ DEFAULT_STYLE_NAME = "2560 x 1440"
 
 
 
 
75
 
76
  def apply_style(style_name: str, positive: str, negative: str = "") -> Tuple[str, str]:
77
+ p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
 
 
 
 
 
 
 
 
78
  if not negative:
79
  negative = ""
80
  return p.replace("{prompt}", positive), n + negative
81
 
82
+
83
+
84
 
85
 
86
+ DESCRIPTION = """## MidJourney
87
+
88
+ Drop your best results in the community: [rb.gy/klkbs7](http://rb.gy/klkbs7), Have you tried the dalle collage space? [rb.gy/xkmlh4](http://rb.gy/xkmlh4)
89
  """
90
 
91
+
92
+
93
+
94
+
95
+ if not torch.cuda.is_available():
96
+ DESCRIPTION += "\n<p>⚠️Running on CPU, This may not work on CPU.</p>"
97
+
98
  MAX_SEED = np.iinfo(np.int32).max
99
+ CACHE_EXAMPLES = torch.cuda.is_available() and os.getenv("CACHE_EXAMPLES", "0") == "1"
100
  MAX_IMAGE_SIZE = int(os.getenv("MAX_IMAGE_SIZE", "2048"))
101
+ USE_TORCH_COMPILE = os.getenv("USE_TORCH_COMPILE", "0") == "1"
102
+ ENABLE_CPU_OFFLOAD = os.getenv("ENABLE_CPU_OFFLOAD", "0") == "1"
103
 
104
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
105
 
106
+ NUM_IMAGES_PER_PROMPT = 1
107
+
108
  if torch.cuda.is_available():
109
  pipe = DiffusionPipeline.from_pretrained(
110
+ "SG161222/RealVisXL_V3.0_Turbo",
111
  torch_dtype=torch.float16,
112
  use_safetensors=True,
113
  add_watermarker=False,
114
  variant="fp16"
115
+ )
116
+ pipe2 = DiffusionPipeline.from_pretrained(
117
+ "SG161222/RealVisXL_V2.02_Turbo",
118
+ torch_dtype=torch.float16,
119
+ use_safetensors=True,
120
+ add_watermarker=False,
121
+ variant="fp16"
122
+ )
123
  if ENABLE_CPU_OFFLOAD:
124
  pipe.enable_model_cpu_offload()
125
+ pipe2.enable_model_cpu_offload()
126
  else:
127
+ pipe.to(device)
128
+ pipe2.to(device)
129
+ print("Loaded on Device!")
130
+
131
  if USE_TORCH_COMPILE:
132
+ pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
133
+ pipe2.unet = torch.compile(pipe2.unet, mode="reduce-overhead", fullgraph=True)
134
+ print("Model Compiled!")
135
 
136
+ def save_image(img):
137
+ unique_name = str(uuid.uuid4()) + ".png"
138
+ img.save(unique_name)
139
+ return unique_name
140
 
141
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
142
  if randomize_seed:
 
149
  negative_prompt: str = "",
150
  use_negative_prompt: bool = False,
151
  style: str = DEFAULT_STYLE_NAME,
 
 
 
152
  seed: int = 0,
153
+ width: int = 1024,
154
+ height: int = 1024,
155
  guidance_scale: float = 3,
156
  randomize_seed: bool = False,
157
  use_resolution_binning: bool = True,
 
160
  if check_text(prompt, negative_prompt):
161
  raise ValueError("Prompt contains restricted words.")
162
 
163
+ prompt, negative_prompt = apply_style(style, prompt, negative_prompt)
 
 
 
 
 
 
164
  seed = int(randomize_seed_fn(seed, randomize_seed))
165
  generator = torch.Generator().manual_seed(seed)
166
 
 
168
  negative_prompt = "" # type: ignore
169
  negative_prompt += default_negative
170
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  options = {
172
  "prompt": prompt,
173
  "negative_prompt": negative_prompt,
174
  "width": width,
175
  "height": height,
176
  "guidance_scale": guidance_scale,
177
+ "num_inference_steps": 25,
178
  "generator": generator,
179
+ "num_images_per_prompt": NUM_IMAGES_PER_PROMPT,
180
  "use_resolution_binning": use_resolution_binning,
181
  "output_type": "pil",
182
  }
183
 
184
+ images = pipe(**options).images + pipe2(**options).images
 
 
 
185
 
186
+ image_paths = [save_image(img) for img in images]
187
+ return image_paths, seed
 
 
 
 
188
 
189
  examples = [
190
+ "A closeup of a cat, a window, in a rustic cabin, close up, with a shallow depth of field, with a vintage film grain, in the style of Annie Leibovitz and in the style of Wes Anderson. --ar 85:128 --v 6.0 --style raw",
191
+ "Daria Morgendorffer the main character of the animated series Daria, serious expression, very excites sultry look, so hot girl, beautiful charismatic girl, so hot shot, a woman wearing eye glasses, gorgeous figure, interesting shapes, life-size figures",
192
+ "Dark green large leaves of anthurium, close up, photography, aerial view, in the style of unsplash, hasselblad h6d400c --ar 85:128 --v 6.0 --style raw",
193
  "Closeup of blonde woman depth of field, bokeh, shallow focus, minimalism, fujifilm xh2s with Canon EF lens, cinematic --ar 85:128 --v 6.0 --style raw"
194
  ]
195
 
196
  css = '''
197
+ .gradio-container{max-width: 700px !important}
198
  h1{text-align:center}
199
  '''
200
  with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
 
214
  container=False,
215
  )
216
  run_button = gr.Button("Run")
217
+ result = gr.Gallery(label="Result", columns=1, preview=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  with gr.Accordion("Advanced options", open=False):
219
  use_negative_prompt = gr.Checkbox(label="Use negative prompt", value=True, visible=True)
220
  negative_prompt = gr.Text(
221
  label="Negative prompt",
222
  max_lines=1,
223
  placeholder="Enter a negative prompt",
224
+ value="(deformed iris, deformed pupils, semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime:1.4), text, close up, cropped, out of frame, worst quality, low quality, jpeg artifacts, ugly, duplicate, morbid, mutilated, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, mutation, deformed, blurry, dehydrated, bad anatomy, bad proportions, extra limbs, cloned face, disfigured, gross proportions, malformed limbs, missing arms, missing legs, extra arms, extra legs, fused fingers, too many fingers, long neck",
225
  visible=True,
226
  )
227
  with gr.Row():
228
  num_inference_steps = gr.Slider(
229
  label="Steps",
230
  minimum=10,
231
+ maximum=60,
232
  step=1,
233
+ value=30,
234
  )
235
  with gr.Row():
236
  num_images_per_prompt = gr.Slider(
 
249
  visible=True
250
  )
251
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
 
252
  with gr.Row(visible=True):
253
  width = gr.Slider(
254
  label="Width",
 
264
  step=8,
265
  value=1024,
266
  )
 
267
  with gr.Row():
268
  guidance_scale = gr.Slider(
269
  label="Guidance Scale",
 
272
  step=0.1,
273
  value=6,
274
  )
275
+ with gr.Row(visible=True):
276
+ style_selection = gr.Radio(
277
+ show_label=True,
278
+ container=True,
279
+ interactive=True,
280
+ choices=STYLE_NAMES,
281
+ value=DEFAULT_STYLE_NAME,
282
+ label="Image Style",
283
+ )
284
  gr.Examples(
285
  examples=examples,
286
  inputs=prompt,
287
  outputs=[result, seed],
288
  fn=generate,
 
289
  cache_examples=CACHE_EXAMPLES,
290
  )
291
 
 
308
  negative_prompt,
309
  use_negative_prompt,
310
  style_selection,
 
 
 
311
  seed,
312
  width,
313
  height,
 
319
  )
320
 
321
  if __name__ == "__main__":
322
+ demo.queue(max_size=20).launch()
requirements.txt CHANGED
@@ -1,11 +1,7 @@
1
- diffusers
2
  torch
3
- torchvision
4
- pipeline
5
  transformers
6
- accelerate
7
  safetensors
 
8
  spaces
9
- peft
10
- gradio
11
- pillow
 
 
1
  torch
2
+ diffusers
 
3
  transformers
 
4
  safetensors
5
+ accelerate
6
  spaces
7
+ peft