prithivMLmods commited on
Commit
0de2127
1 Parent(s): 61f263e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +139 -59
app.py CHANGED
@@ -1,5 +1,5 @@
1
  #!/usr/bin/env python
2
- #patch 2.0 ()
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
  # of this software and associated documentation files (the "Software"), to deal
5
  # in the Software without restriction, including without limitation the rights
@@ -35,38 +35,7 @@ def check_text(prompt, negative=""):
35
  return True
36
  return False
37
 
38
-
39
- #Load the HTML content
40
- #html_file_url = "https://prithivmlmods-hamster-static.static.hf.space/index.html"
41
- #html_content = f'<iframe src="{html_file_url}" style="width:100%; height:180px; border:none;"></iframe>'
42
- #html_file_url = "https://prithivmlmods-static-loading-theme.static.hf.space/index.html"
43
- #html_file_url = ""
44
- #html_content = f'<iframe src="{html_file_url}" style="width:100%; height:400px; border:none"></iframe>'
45
-
46
-
47
-
48
- #js_func = """
49
-
50
- #<script>
51
- #(function() {
52
- # const url = new URL(window.location);
53
- # const currentTheme = url.searchParams.get('__theme');
54
-
55
- # if (currentTheme !== 'dark') {
56
- # url.searchParams.set('__theme', 'dark');
57
- # history.pushState({}, '', url.href);
58
- # applyDarkTheme();
59
- # }
60
- #})();
61
-
62
- #function applyDarkTheme() {
63
- # // Example: Apply dark theme styles to body or specific elements
64
- # document.body.classList.add('dark-theme');
65
- # // Additional logic as needed
66
- #}
67
- #</script>
68
- #"""
69
-
70
 
71
  style_list = [
72
  {
@@ -94,6 +63,8 @@ style_list = [
94
 
95
  ]
96
 
 
 
97
  collage_style_list = [
98
  {
99
  "name": "Hi-Res",
@@ -151,6 +122,73 @@ collage_style_list = [
151
  "negative_prompt": "random, messy, unorganized, clashing colors",
152
  },
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  {
155
  "name": "No Style",
156
  "prompt": "{prompt}",
@@ -159,6 +197,8 @@ collage_style_list = [
159
 
160
  ]
161
 
 
 
162
  filters = {
163
  "Vivid": {
164
  "prompt": "extra vivid {prompt}",
@@ -247,7 +287,7 @@ device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
247
  #Compile
248
  if torch.cuda.is_available():
249
  pipe = StableDiffusionXLPipeline.from_pretrained(
250
- "SG161222/RealVisXL_V4.0",
251
  torch_dtype=torch.float16,
252
  use_safetensors=True,
253
  add_watermarker=False,
@@ -272,6 +312,36 @@ def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
272
  seed = random.randint(0, MAX_SEED)
273
  return seed
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
  @spaces.GPU(enable_queue=True)
276
  def generate(
277
  prompt: str,
@@ -343,6 +413,19 @@ def generate(
343
  save_image(grid_img, unique_name)
344
  return [unique_name], seed
345
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
 
347
  def load_predefined_images():
348
  predefined_images = [
@@ -358,13 +441,13 @@ def load_predefined_images():
358
  ]
359
  return predefined_images
360
 
361
-
362
  examples = [
363
 
364
- "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",
365
  "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)",
366
  "Cold coffee in a cup bokeh --ar 85:128 --v 6.0 --style raw5, 4K, Photo-Realistic",
367
- "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"
 
368
  ]
369
 
370
  css = '''
@@ -372,9 +455,7 @@ css = '''
372
  h1{text-align:center}
373
  '''
374
 
375
- #with gr.Blocks(css=css, theme="bethecloud/storj_theme", js=js_func) as demo:
376
  with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
377
- #with gr.Blocks(css=css, theme="Nymbo/Alyx_Theme") as demo:
378
  gr.Markdown(DESCRIPTION)
379
  gr.DuplicateButton(
380
  value="Duplicate Space for private use",
@@ -412,23 +493,23 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
412
  )
413
 
414
  with gr.Row(visible=True):
415
- style_selection = gr.Radio(
416
  show_label=True,
417
  container=True,
418
  interactive=True,
419
- choices=STYLE_NAMES,
420
- value=DEFAULT_STYLE_NAME,
421
- label="Quality Style",
422
  )
423
-
424
  with gr.Row(visible=True):
425
- collage_style_selection = gr.Radio(
426
  show_label=True,
427
  container=True,
428
  interactive=True,
429
- choices=COLLAGE_STYLE_NAMES,
430
- value=DEFAULT_COLLAGE_STYLE_NAME,
431
- label="Collage Template",
432
  )
433
 
434
  with gr.Accordion("Advanced options", open=False):
@@ -531,18 +612,17 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
531
  outputs=[result, seed],
532
  api_name="run",
533
  )
534
- # Adding a predefined gallery
535
- gr.Markdown("### Gallery Images")
536
- predefined_gallery = gr.Gallery(label="Gallery Images", columns=3, show_label=False, value=load_predefined_images())
537
- #gr.Markdown("⚠️ responsible for ensuring it meets appropriate ethical standards")
538
- gr.Markdown(DESCRIPTIONy)
539
 
540
- # Adding a disclaimer
541
- gr.Markdown("**Disclaimer:**")
542
- gr.Markdown("This is the demo space for generating images using Stable Diffusion with grids, filters, templates, quality styles, and types. Try the sample prompts to generate higher quality images. Try the sample prompts for generating higher quality images.<a href='https://huggingface.co/spaces/prithivMLmods/Top-Prompt-Collection' target='_blank'>Try prompts</a>.")
543
- gr.Markdown("**Local or Colab ??:**")
544
- gr.Markdown("This repository helps you run and work with Hugging Face spaces on your local CPU or using Colab Notebooks. If you find it helpful, give it a like or starring the repository.<a href='https://github.com/PRITHIVSAKTHIUR/How-to-run-huggingface-spaces-on-local-machine-demo' target='_blank'>Visit repo.</a>.")
545
- gr.Markdown("**Note:**")
 
 
 
 
546
  gr.Markdown("⚠️ users are accountable for the content they generate and are responsible for ensuring it meets appropriate ethical standards.")
547
  #gr.HTML(html_content)
548
 
 
1
  #!/usr/bin/env python
2
+ #patch 3.0 ()
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
  # of this software and associated documentation files (the "Software"), to deal
5
  # in the Software without restriction, including without limitation the rights
 
35
  return True
36
  return False
37
 
38
+ #Quality/Style-----------------------------------------------------------------------------------------------------------------------------------------------------------Quality/Style
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  style_list = [
41
  {
 
63
 
64
  ]
65
 
66
+ #Clgstyle--------------------------------------------------------------------------------------------------------------------------------------------------------------Clgstyle
67
+
68
  collage_style_list = [
69
  {
70
  "name": "Hi-Res",
 
122
  "negative_prompt": "random, messy, unorganized, clashing colors",
123
  },
124
 
125
+ #DuoTones by Canva --------------------------------------------------------------------------------------------------------------- Alters only the i++ Part / not Zero Tones
126
+
127
+ {
128
+ "name": "Cherry",
129
+ "prompt": "Duotone style Cherry tone applied to {prompt}",
130
+ "negative_prompt": "",
131
+ },
132
+ {
133
+ "name": "Fuchsia",
134
+ "prompt": "Duotone style Fuchsia tone applied to {prompt}",
135
+ "negative_prompt": "",
136
+ },
137
+ {
138
+ "name": "Pop",
139
+ "prompt": "Duotone style Pop tone applied to {prompt}",
140
+ "negative_prompt": "",
141
+ },
142
+ {
143
+ "name": "Violet",
144
+ "prompt": "Duotone style Violet applied to {prompt}",
145
+ "negative_prompt": "",
146
+ },
147
+ {
148
+ "name": "Sea Blue",
149
+ "prompt": "Duotone style Sea Blue applied to {prompt}",
150
+ "negative_prompt": "",
151
+ },
152
+ {
153
+ "name": "Sea Green",
154
+ "prompt": "Duotone style Sea Green applied to {prompt}",
155
+ "negative_prompt": "",
156
+ },
157
+ {
158
+ "name": "Mustard",
159
+ "prompt": "Duotone style Mustard applied to {prompt}",
160
+ "negative_prompt": "",
161
+ },
162
+ {
163
+ "name": "Amber",
164
+ "prompt": "Duotone style Amber applied to {prompt}",
165
+ "negative_prompt": "",
166
+ },
167
+ {
168
+ "name": "Pomelo",
169
+ "prompt": "Duotone style Pomelo applied to {prompt}",
170
+ "negative_prompt": "",
171
+ },
172
+ {
173
+ "name": "Peppermint",
174
+ "prompt": "Duotone style Peppermint applied to {prompt}",
175
+ "negative_prompt": "",
176
+ },
177
+ {
178
+ "name": "Mystic",
179
+ "prompt": "Duotone style Mystic tone applied to {prompt}",
180
+ "negative_prompt": "",
181
+ },
182
+ {
183
+ "name": "Pastel",
184
+ "prompt": "Duotone style Pastel applied to {prompt}",
185
+ "negative_prompt": "",
186
+ },
187
+ {
188
+ "name": "Coral",
189
+ "prompt": "Duotone style Coral applied to {prompt}",
190
+ "negative_prompt": "",
191
+ },
192
  {
193
  "name": "No Style",
194
  "prompt": "{prompt}",
 
197
 
198
  ]
199
 
200
+ #filters------------------------------------------------------------------------------------------------------------------------------------------------filters
201
+
202
  filters = {
203
  "Vivid": {
204
  "prompt": "extra vivid {prompt}",
 
287
  #Compile
288
  if torch.cuda.is_available():
289
  pipe = StableDiffusionXLPipeline.from_pretrained(
290
+ "SG161222/RealVisXL_V4.0_Lightning", #(or) use --- SG161222/RealVisXL_V4.0 / SG161222/RealVisXL_V4.0_Lightning --- for better results.
291
  torch_dtype=torch.float16,
292
  use_safetensors=True,
293
  add_watermarker=False,
 
312
  seed = random.randint(0, MAX_SEED)
313
  return seed
314
 
315
+ #Load the HTML content
316
+ #html_file_url = "https://prithivmlmods-hamster-static.static.hf.space/index.html"
317
+ #html_content = f'<iframe src="{html_file_url}" style="width:100%; height:180px; border:none;"></iframe>'
318
+ #html_file_url = "https://prithivmlmods-static-loading-theme.static.hf.space/index.html"
319
+ #html_file_url = ""
320
+ #html_content = f'<iframe src="{html_file_url}" style="width:100%; height:400px; border:none"></iframe>'
321
+
322
+
323
+ #js_func = """
324
+
325
+ #<script>
326
+ #(function() {
327
+ # const url = new URL(window.location);
328
+ # const currentTheme = url.searchParams.get('__theme');
329
+
330
+ # if (currentTheme !== 'dark') {
331
+ # url.searchParams.set('__theme', 'dark');
332
+ # history.pushState({}, '', url.href);
333
+ # applyDarkTheme();
334
+ # }
335
+ #})();
336
+
337
+ #function applyDarkTheme() {
338
+ # // Example: Apply dark theme styles to body or specific elements
339
+ # document.body.classList.add('dark-theme');
340
+ # // Additional logic as needed
341
+ #}
342
+ #</script>
343
+ #"""
344
+
345
  @spaces.GPU(enable_queue=True)
346
  def generate(
347
  prompt: str,
 
413
  save_image(grid_img, unique_name)
414
  return [unique_name], seed
415
 
416
+ def load_predefined_images1():
417
+ predefined_images1 = [
418
+ "Tones/1.png",
419
+ "Tones/2.png",
420
+ "Tones/3.png",
421
+ "Tones/4.png",
422
+ "Tones/5.png",
423
+ "Tones/6.png",
424
+ "Tones/7.png",
425
+ "Tones/8.png",
426
+ "Tones/9.png",
427
+ ]
428
+ return predefined_images1
429
 
430
  def load_predefined_images():
431
  predefined_images = [
 
441
  ]
442
  return predefined_images
443
 
 
444
  examples = [
445
 
446
+ "Chocolate dripping from a donut against a yellow background, in the style of brocore, hyper-realistic oil --ar 2:3 --q 2 --s 750 --v 5 --ar 2:3 --q 2 --s 750 --v 5",
447
  "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)",
448
  "Cold coffee in a cup bokeh --ar 85:128 --v 6.0 --style raw5, 4K, Photo-Realistic",
449
+ "Food photography of a milk shake with flying strawberrys against a pink background, professionally studio shot with cinematic lighting. The image is in the style of a professional studio shot --ar 85:128 --v 6.0 --style raw"
450
+
451
  ]
452
 
453
  css = '''
 
455
  h1{text-align:center}
456
  '''
457
 
 
458
  with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
 
459
  gr.Markdown(DESCRIPTION)
460
  gr.DuplicateButton(
461
  value="Duplicate Space for private use",
 
493
  )
494
 
495
  with gr.Row(visible=True):
496
+ collage_style_selection = gr.Radio(
497
  show_label=True,
498
  container=True,
499
  interactive=True,
500
+ choices=COLLAGE_STYLE_NAMES,
501
+ value=DEFAULT_COLLAGE_STYLE_NAME,
502
+ label="Collage Template + Duotone Canvas",
503
  )
504
+
505
  with gr.Row(visible=True):
506
+ style_selection = gr.Radio(
507
  show_label=True,
508
  container=True,
509
  interactive=True,
510
+ choices=STYLE_NAMES,
511
+ value=DEFAULT_STYLE_NAME,
512
+ label="Quality Style",
513
  )
514
 
515
  with gr.Accordion("Advanced options", open=False):
 
612
  outputs=[result, seed],
613
  api_name="run",
614
  )
 
 
 
 
 
615
 
616
+ gr.Markdown("### Duotone Canvas")
617
+ predefined_gallery = gr.Gallery(label="Duotone Canvas", columns=3, show_label=False, value=load_predefined_images1())
618
+
619
+ gr.Markdown("### Image Gallery")
620
+ predefined_gallery = gr.Gallery(label="Image Gallery", columns=3, show_label=False, value=load_predefined_images())
621
+
622
+ gr.Markdown(DESCRIPTIONy)
623
+ gr.Markdown("**Disclaimer/Note:**")
624
+ gr.Markdown("🏞️This is the demo space for generating images using Stable Diffusion with grids, filters, templates, quality styles, and types. Try the sample prompts to generate higher quality images. Try the sample prompts for generating higher quality images.<a href='https://huggingface.co/spaces/prithivMLmods/Top-Prompt-Collection' target='_blank'>Try prompts</a>.")
625
+ gr.Markdown("🏞️This repository helps you run and work with Hugging Face spaces on your local CPU or using Colab Notebooks. If you find it helpful, give it a like or starring the repository.<a href='https://github.com/PRITHIVSAKTHIUR/How-to-run-huggingface-spaces-on-local-machine-demo' target='_blank'>Visit repo.</a>.")
626
  gr.Markdown("⚠️ users are accountable for the content they generate and are responsible for ensuring it meets appropriate ethical standards.")
627
  #gr.HTML(html_content)
628