John6666 commited on
Commit
66a1189
β€’
1 Parent(s): be41a7e

Upload genimage.py

Browse files
Files changed (1) hide show
  1. genimage.py +10 -8
genimage.py CHANGED
@@ -7,7 +7,8 @@ def load_pipeline():
7
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
8
  pipe = AutoPipelineForText2Image.from_pretrained(
9
  "John6666/rae-diffusion-xl-v2-sdxl-spo-pcm",
10
- custom_pipeline="lpw_stable_diffusion_xl",
 
11
  torch_dtype=torch.float16,
12
  )
13
  pipe.to(device)
@@ -35,11 +36,11 @@ pipe = load_pipeline()
35
  @spaces.GPU
36
  def generate_image(prompt, neg_prompt):
37
  metadata = {
38
- "prompt": prompt,
39
- "negative_prompt": neg_prompt,
40
  "resolution": f"{1024} x {1024}",
41
- "guidance_scale": 7.5,
42
- "num_inference_steps": 24,
43
  "sampler": "Euler",
44
  }
45
  try:
@@ -48,10 +49,10 @@ def generate_image(prompt, neg_prompt):
48
  negative_prompt=neg_prompt + ", bad hands, bad feet, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract], photo, deformed, disfigured, low contrast, photo, deformed, disfigured, low contrast",
49
  width=1024,
50
  height=1024,
51
- guidance_scale=7.5,
52
- num_inference_steps=24,
53
  output_type="pil",
54
- clip_skip=1,
55
  ).images
56
  if images:
57
  image_paths = [
@@ -60,5 +61,6 @@ def generate_image(prompt, neg_prompt):
60
  ]
61
  return image_paths
62
  except Exception as e:
 
63
  return []
64
 
 
7
  device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
8
  pipe = AutoPipelineForText2Image.from_pretrained(
9
  "John6666/rae-diffusion-xl-v2-sdxl-spo-pcm",
10
+ #custom_pipeline="lpw_stable_diffusion_xl",
11
+ custom_pipeline="nyanko7/sdxl_smoothed_energy_guidance",
12
  torch_dtype=torch.float16,
13
  )
14
  pipe.to(device)
 
36
  @spaces.GPU
37
  def generate_image(prompt, neg_prompt):
38
  metadata = {
39
+ "prompt": prompt + ", anime, masterpiece, best quality, very aesthetic, absurdres",
40
+ "negative_prompt": neg_prompt + ", bad hands, bad feet, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract], photo, deformed, disfigured, low contrast, photo, deformed, disfigured, low contrast",
41
  "resolution": f"{1024} x {1024}",
42
+ "guidance_scale": 7.0,
43
+ "num_inference_steps": 28,
44
  "sampler": "Euler",
45
  }
46
  try:
 
49
  negative_prompt=neg_prompt + ", bad hands, bad feet, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, [abstract], photo, deformed, disfigured, low contrast, photo, deformed, disfigured, low contrast",
50
  width=1024,
51
  height=1024,
52
+ guidance_scale=7.0, seg_scale=3.0, seg_applied_layers=["mid"],
53
+ num_inference_steps=28,
54
  output_type="pil",
55
+ #clip_skip=1,
56
  ).images
57
  if images:
58
  image_paths = [
 
61
  ]
62
  return image_paths
63
  except Exception as e:
64
+ print(e)
65
  return []
66