John6666 commited on
Commit
92ca851
·
verified ·
1 Parent(s): 97cf4f0

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +15 -15
  2. app.py +3 -3
  3. externalmod.py +27 -0
README.md CHANGED
@@ -1,16 +1,16 @@
1
- ---
2
- title: 872 AI Art Models Printing Press (Gradio 4.x)
3
- emoji: 👩‍🎨👨‍🎨
4
- colorFrom: red
5
- colorTo: green
6
- sdk: gradio
7
- sdk_version: 4.39.0
8
- app_file: app.py
9
- pinned: false
10
- duplicated_from:
11
- - Omnibus/maximum_multiplier_places
12
- - Yntec/PrintingPress
13
- short_description: Generate up to 6 images from 1 prompt!
14
- ---
15
-
16
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+ ---
2
+ title: 872 AI Art Models Printing Press (Gradio 5.x)
3
+ emoji: 👩‍🎨👨‍🎨
4
+ colorFrom: red
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 5.0.1
8
+ app_file: app.py
9
+ pinned: false
10
+ duplicated_from:
11
+ - Omnibus/maximum_multiplier_places
12
+ - Yntec/PrintingPress
13
+ short_description: Generate up to 6 images from 1 prompt!
14
+ ---
15
+
16
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py CHANGED
@@ -101,7 +101,7 @@ css="""
101
  .output { width=128px; height=128px; !important; }
102
  .outputone { width=512px; height=512px; !important; }
103
  """
104
- with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as demo:
105
  gr.HTML(
106
  """
107
  <div>
@@ -188,7 +188,7 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as demo:
188
  with gr.Row():
189
  output2 = [gr.Image(label = '', show_download_button=True, elem_classes="output",
190
  interactive=False, min_width=80, visible=True, format="png",
191
- show_share_button=False, show_label=False) for _ in range(max_images)]
192
 
193
  for i, o in enumerate(output2):
194
  img_i = gr.Number(i, visible=False)
@@ -208,5 +208,5 @@ with gr.Blocks(theme='Nymbo/Nymbo_Theme', fill_width=True, css=css) as demo:
208
  """
209
  )
210
 
211
- demo.queue(default_concurrency_limit=200, max_size=200)
212
  demo.launch(show_api=False, max_threads=400)
 
101
  .output { width=128px; height=128px; !important; }
102
  .outputone { width=512px; height=512px; !important; }
103
  """
104
+ with gr.Blocks(theme='NoCrypt/miku@>=1.2.2', fill_width=True, css=css) as demo:
105
  gr.HTML(
106
  """
107
  <div>
 
188
  with gr.Row():
189
  output2 = [gr.Image(label = '', show_download_button=True, elem_classes="output",
190
  interactive=False, min_width=80, visible=True, format="png",
191
+ show_share_button=False, show_label=False, width=128, height=128) for _ in range(max_images)]
192
 
193
  for i, o in enumerate(output2):
194
  img_i = gr.Number(i, visible=False)
 
208
  """
209
  )
210
 
211
+ #demo.queue(default_concurrency_limit=200, max_size=200)
212
  demo.launch(show_api=False, max_threads=400)
externalmod.py CHANGED
@@ -583,3 +583,30 @@ def find_model_list(author: str="", tags: list[str]=[], not_tag="", sort: str="l
583
  models.append(model.id)
584
  if len(models) == limit: break
585
  return models
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
583
  models.append(model.id)
584
  if len(models) == limit: break
585
  return models
586
+
587
+
588
+ def save_image(image, savefile, modelname, prompt, nprompt, height=0, width=0, steps=0, cfg=0, seed=-1):
589
+ from PIL import Image, PngImagePlugin
590
+ import json
591
+ try:
592
+ metadata = {"prompt": prompt, "negative_prompt": nprompt, "Model": {"Model": modelname.split("/")[-1]}}
593
+ if steps > 0: metadata["num_inference_steps"] = steps
594
+ if cfg > 0: metadata["guidance_scale"] = cfg
595
+ if seed != -1: metadata["seed"] = seed
596
+ if width > 0 and height > 0: metadata["resolution"] = f"{width} x {height}"
597
+ metadata_str = json.dumps(metadata)
598
+ info = PngImagePlugin.PngInfo()
599
+ info.add_text("metadata", metadata_str)
600
+ image.save(savefile, "PNG", pnginfo=info)
601
+ return str(Path(savefile).resolve())
602
+ except Exception as e:
603
+ print(f"Failed to save image file: {e}")
604
+ raise Exception(f"Failed to save image file:") from e
605
+
606
+
607
+ def randomize_seed():
608
+ from random import seed, randint
609
+ MAX_SEED = 2**32-1
610
+ seed()
611
+ rseed = randint(0, MAX_SEED)
612
+ return rseed