developerskyebrowse commited on
Commit
cd05b35
·
1 Parent(s): e64952a
Files changed (2) hide show
  1. app.py +0 -22
  2. local_app.py +64 -96
app.py CHANGED
@@ -351,28 +351,6 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
351
  yield None, gr.update()
352
  result = process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
353
  yield gr.update(), result
354
-
355
- # # Change input to result
356
- # @gr.on(triggers=[use_ai_button.click], inputs=None, outputs=image, show_progress="hidden")
357
- # def update_input():
358
- # try:
359
- # print("Updating image to AI Temp Image")
360
- # ai_temp_image = Image.open("temp_image.jpg")
361
- # return ai_temp_image
362
- # except FileNotFoundError:
363
- # print("No AI Image Available")
364
- # return None
365
-
366
- # # AI Image Processing
367
- # @gr.on(triggers=[use_ai_button.click], inputs=config, outputs=[result, image], show_progress="minimal")
368
- # def submit(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
369
- # try:
370
- # print("Updating image to AI Temp Image")
371
- # image = Image.open("temp_image.jpg")
372
- # except FileNotFoundError:
373
- # print("No AI Image Available")
374
- # return None
375
- # return process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed), image
376
 
377
  # Turn off buttons when processing
378
  @gr.on(triggers=[image.upload, use_ai_button.click, run_button.click], inputs=None, outputs=[run_button, use_ai_button], show_progress="hidden")
 
351
  yield None, gr.update()
352
  result = process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
353
  yield gr.update(), result
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
 
355
  # Turn off buttons when processing
356
  @gr.on(triggers=[image.upload, use_ai_button.click, run_button.click], inputs=None, outputs=[run_button, use_ai_button], show_progress="hidden")
local_app.py CHANGED
@@ -6,7 +6,6 @@ if prod:
6
  # show_options = False
7
 
8
  import os
9
- import gc
10
  import random
11
  import time
12
  import gradio as gr
@@ -20,20 +19,16 @@ from diffusers import (
20
  StableDiffusionControlNetPipeline,
21
  AutoencoderKL,
22
  )
23
- from diffusers.models.attention_processor import AttnProcessor2_0
24
  MAX_SEED = np.iinfo(np.int32).max
25
  API_KEY = os.environ.get("API_KEY", None)
26
 
27
  print("CUDA version:", torch.version.cuda)
28
- print("loading pipe")
29
  compiled = False
30
 
31
  if gr.NO_RELOAD:
32
- from preprocess import Preprocessor
33
- preprocessor = Preprocessor()
34
- # preprocessor.load("NormalBae")
35
  torch.cuda.max_memory_allocated(device="cuda")
36
-
37
  # Controlnet Normal
38
  model_id = "lllyasviel/control_v11p_sd15_normalbae"
39
  print("initializing controlnet")
@@ -42,37 +37,41 @@ if gr.NO_RELOAD:
42
  torch_dtype=torch.float16,
43
  attn_implementation="flash_attention_2",
44
  ).to("cuda")
45
-
46
  # Scheduler
47
  scheduler = DPMSolverMultistepScheduler.from_pretrained(
48
- "stabilityai/stable-diffusion-xl-base-1.0",
 
49
  subfolder="scheduler",
50
  use_karras_sigmas=True,
51
- # final_sigmas_type="sigma_min",
52
  algorithm_type="sde-dpmsolver++",
53
- # prediction_type="epsilon",
54
- # thresholding=False,
55
  denoise_final=True,
56
  device_map="cuda",
57
- attn_implementation="flash_attention_2",
58
  )
59
 
60
  # Stable Diffusion Pipeline URL
61
  # base_model_url = "https://huggingface.co/broyang/hentaidigitalart_v20/blob/main/realcartoon3d_v15.safetensors"
62
  base_model_url = "https://huggingface.co/Lykon/AbsoluteReality/blob/main/AbsoluteReality_1.8.1_pruned.safetensors"
63
- base_model_id = "Lykon/absolute-reality-1.81"
64
  vae_url = "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/blob/main/vae-ft-mse-840000-ema-pruned.safetensors"
65
-
 
66
  vae = AutoencoderKL.from_single_file(vae_url, torch_dtype=torch.float16).to("cuda")
67
  vae.to(memory_format=torch.channels_last)
68
 
 
69
  pipe = StableDiffusionControlNetPipeline.from_single_file(
70
  base_model_url,
 
 
71
  controlnet=controlnet,
72
  scheduler=scheduler,
73
  vae=vae,
74
  torch_dtype=torch.float16,
75
- ).to("cuda")
76
 
77
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="EasyNegativeV2.safetensors", token="EasyNegativeV2",)
78
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="badhandv4.pt", token="badhandv4")
@@ -85,15 +84,15 @@ if gr.NO_RELOAD:
85
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="HDA_NunDress.pt", token="HDA_NunDress")
86
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="HDA_Shibari.pt", token="HDA_Shibari")
87
  pipe.to("cuda")
88
-
 
 
 
 
 
89
  print("---------------Loaded controlnet pipeline---------------")
 
90
 
91
- # @spaces.GPU(duration=12)
92
- pipe.unet.set_attn_processor(AttnProcessor2_0())
93
- torch.cuda.empty_cache()
94
- gc.collect()
95
- print("Model Compiled!")
96
-
97
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
98
  if randomize_seed:
99
  seed = random.randint(0, MAX_SEED)
@@ -132,7 +131,7 @@ def get_prompt(prompt, additional_prompt):
132
  girls = [randomize, pet_play, bondage, lab_girl, athleisure, atompunk, maid, nundress, naked_hoodie, abg, shibari2, ahegao2]
133
  prompts_nsfw = [abg, shibari2, ahegao2]
134
  prompt = f"{random.choice(girls)}"
135
- # prompt = f"boho chic"
136
  # print(f"-------------{preset}-------------")
137
  else:
138
  prompt = f"Photo from Pinterest of {prompt} {interior}"
@@ -149,7 +148,7 @@ style_list = [
149
  "prompt": "Minimalist interior design, clean lines, neutral colors, uncluttered space, functional furniture, lots of natural light"
150
  },
151
  {
152
- "name": "Boho Chic",
153
  "prompt": "Bohemian chic interior, eclectic mix of patterns and textures, vintage furniture, plants, woven textiles, warm earthy colors"
154
  },
155
  {
@@ -213,40 +212,27 @@ def apply_style(style_name):
213
  if style_name in styles:
214
  p = styles.get(style_name, "boho chic")
215
  return p
216
-
 
217
  css = """
218
- h1, h2, h3 {
219
  text-align: center;
220
- display: block;
221
- }
222
-
223
- .gradio-container {
224
- max-width: 1200px !important;
225
  }
226
-
227
- footer {
228
- visibility: hidden;
229
- }
230
-
231
- .gr-image {
232
- display: flex;
233
- justify-content: center;
234
- align-items: center;
235
- width: 100%;
236
- height: 512px;
237
- overflow: hidden;
238
  }
239
-
240
- .gr-image img {
241
- width: 100%;
242
- height: 100%;
243
- object-fit: cover;
244
- object-position: center;
245
  }
 
 
246
  """
247
  with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
248
  #############################################################################
249
- with gr.Row():
250
  with gr.Accordion("Advanced options", open=show_options, visible=show_options):
251
  num_images = gr.Slider(
252
  label="Images", minimum=1, maximum=4, value=1, step=1
@@ -275,23 +261,20 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
275
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
276
  a_prompt = gr.Textbox(
277
  label="Additional prompt",
278
- value = "design-style interior designed (interior space), captured with a DSLR camera using f/10 aperture, 1/60 sec shutter speed, ISO 400, 20mm focal length, tungsten white balance, (sharp focus), professional photography, high-resolution, 8k, Pulitzer Prize-winning"
279
  )
280
  n_prompt = gr.Textbox(
281
  label="Negative prompt",
282
  value="EasyNegativeV2, fcNeg, (badhandv4:1.4), (worst quality, low quality, bad quality, normal quality:2.0), (bad hands, missing fingers, extra fingers:2.0)",
283
  )
284
  #############################################################################
285
- # input text
286
- # with gr.Row():
287
- # gr.Text(label="Interior Design Style Examples", value="Eclectic, Maximalist, Bohemian, Scandinavian, Minimalist, Rustic, Modern Farmhouse, Contemporary, Luxury, Airbnb, Boho Chic, Midcentury Modern, Art Deco, Zen, Beach, Neoclassical, Industrial, Biophilic, Eco-friendly, Hollywood Glam, Parisian White, Saudi Prince Gold, French Country, Monster Energy Drink, Cyberpunk, Vaporwave, Baroque, etc.\n\nPro tip: add a color to customize it! You can also describe the furniture type.")
288
  with gr.Column():
289
  prompt = gr.Textbox(
290
- label="Custom Prompt (optional)",
291
- placeholder="use your imagination 👀",
292
  )
293
- with gr.Column(visible=True):
294
- style_selection = gr.Dropdown(
295
  show_label=True,
296
  container=True,
297
  interactive=True,
@@ -299,8 +282,9 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
299
  value="None",
300
  label="Design Styles",
301
  )
302
- with gr.Row(equal_height=True, variant="panel"):
303
- with gr.Column(min_width=300):
 
304
  image = gr.Image(
305
  label="Input",
306
  sources=["upload"],
@@ -308,17 +292,20 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
308
  mirror_webcam=True,
309
  format="webp",
310
  )
 
311
  with gr.Column():
312
- run_button = gr.Button(value="Use this one", size="sm", visible=False)
313
- with gr.Column(min_width=300):
 
314
  result = gr.Image(
315
  label="Output",
316
  interactive=False,
317
  format="webp",
318
  show_share_button= False,
319
  )
 
320
  with gr.Column():
321
- use_ai_button = gr.Button(value="Use this one", size="sm", visible=False)
322
  config = [
323
  image,
324
  style_selection,
@@ -340,23 +327,7 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
340
  @gr.on(triggers=[image.upload, prompt.submit, run_button.click], inputs=config, outputs=result, show_progress="minimal")
341
  def auto_process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
342
  return process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
343
-
344
- # # AI Image Processing
345
- # @gr.on(triggers=[use_ai_button.click], inputs=config, outputs=result, show_progress="minimal")
346
- # def submit(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
347
- # return process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
348
 
349
- # # Change input to result
350
- # @gr.on(triggers=[use_ai_button.click], inputs=None, outputs=image, show_progress="hidden")
351
- # def update_input():
352
- # try:
353
- # print("Updating image to AI Temp Image")
354
- # ai_temp_image = Image.open("temp_image.jpg")
355
- # return ai_temp_image
356
- # except FileNotFoundError:
357
- # print("No AI Image Available")
358
- # return None
359
-
360
  # AI Image Processing and change input
361
  @gr.on(triggers=[use_ai_button.click], inputs=config, outputs=[image, result], show_progress="minimal")
362
  def submit(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
@@ -369,7 +340,7 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
369
  yield None, gr.update()
370
  result = process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
371
  yield gr.update(), result
372
-
373
  # Turn off buttons when processing
374
  @gr.on(triggers=[image.upload, use_ai_button.click, run_button.click], inputs=None, outputs=[run_button, use_ai_button], show_progress="hidden")
375
  def turn_buttons_off():
@@ -380,7 +351,6 @@ with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
380
  def turn_buttons_on():
381
  return gr.update(visible=True), gr.update(visible=True)
382
 
383
- # @spaces.GPU(duration=12)
384
  @torch.inference_mode()
385
  def process_image(
386
  image,
@@ -394,19 +364,17 @@ def process_image(
394
  num_steps,
395
  guidance_scale,
396
  seed,
397
- progress=gr.Progress(track_tqdm=True)
398
  ):
399
  torch.cuda.synchronize()
400
  preprocess_start = time.time()
401
  print("processing image")
402
  preprocessor.load("NormalBae")
403
- # preprocessor.load("Canny") #20 steps, 9 guidance, 512, 512
404
-
405
  global compiled
406
  if not compiled:
407
  print("Not Compiled")
408
  compiled = True
409
-
410
  seed = random.randint(0, MAX_SEED)
411
  generator = torch.cuda.manual_seed(seed)
412
  control_image = preprocessor(
@@ -422,21 +390,21 @@ def process_image(
422
  negative_prompt=str(n_prompt)
423
  print(prompt)
424
  start = time.time()
425
- results = pipe(
426
- prompt=prompt,
427
- negative_prompt=negative_prompt,
428
- guidance_scale=guidance_scale,
429
- num_images_per_prompt=num_images,
430
- num_inference_steps=num_steps,
431
- generator=generator,
432
- image=control_image,
433
- ).images[0]
 
434
  print(f"\n-------------------------Preprocess done in: {preprocess_time:.2f} seconds-------------------------")
435
  print(f"\n-------------------------Inference done in: {time.time() - start:.2f} seconds-------------------------")
436
  results.save("temp_image.jpg")
437
  torch.cuda.synchronize()
438
  torch.cuda.empty_cache()
439
- results.save("temp_image.jpg")
440
  return results
441
 
442
  if prod:
 
6
  # show_options = False
7
 
8
  import os
 
9
  import random
10
  import time
11
  import gradio as gr
 
19
  StableDiffusionControlNetPipeline,
20
  AutoencoderKL,
21
  )
22
+ # from diffusers.models.attention_processor import AttnProcessor2_0
23
  MAX_SEED = np.iinfo(np.int32).max
24
  API_KEY = os.environ.get("API_KEY", None)
25
 
26
  print("CUDA version:", torch.version.cuda)
27
+ print("loading everything")
28
  compiled = False
29
 
30
  if gr.NO_RELOAD:
 
 
 
31
  torch.cuda.max_memory_allocated(device="cuda")
 
32
  # Controlnet Normal
33
  model_id = "lllyasviel/control_v11p_sd15_normalbae"
34
  print("initializing controlnet")
 
37
  torch_dtype=torch.float16,
38
  attn_implementation="flash_attention_2",
39
  ).to("cuda")
40
+
41
  # Scheduler
42
  scheduler = DPMSolverMultistepScheduler.from_pretrained(
43
+ "runwayml/stable-diffusion-v1-5",
44
+ solver_order=2,
45
  subfolder="scheduler",
46
  use_karras_sigmas=True,
47
+ final_sigmas_type="sigma_min",
48
  algorithm_type="sde-dpmsolver++",
49
+ prediction_type="epsilon",
50
+ thresholding=False,
51
  denoise_final=True,
52
  device_map="cuda",
53
+ torch_dtype=torch.float16,
54
  )
55
 
56
  # Stable Diffusion Pipeline URL
57
  # base_model_url = "https://huggingface.co/broyang/hentaidigitalart_v20/blob/main/realcartoon3d_v15.safetensors"
58
  base_model_url = "https://huggingface.co/Lykon/AbsoluteReality/blob/main/AbsoluteReality_1.8.1_pruned.safetensors"
 
59
  vae_url = "https://huggingface.co/stabilityai/sd-vae-ft-mse-original/blob/main/vae-ft-mse-840000-ema-pruned.safetensors"
60
+
61
+ print('loading vae')
62
  vae = AutoencoderKL.from_single_file(vae_url, torch_dtype=torch.float16).to("cuda")
63
  vae.to(memory_format=torch.channels_last)
64
 
65
+ print('loading pipe')
66
  pipe = StableDiffusionControlNetPipeline.from_single_file(
67
  base_model_url,
68
+ safety_checker=None,
69
+ # load_safety_checker=True,
70
  controlnet=controlnet,
71
  scheduler=scheduler,
72
  vae=vae,
73
  torch_dtype=torch.float16,
74
+ )
75
 
76
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="EasyNegativeV2.safetensors", token="EasyNegativeV2",)
77
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="badhandv4.pt", token="badhandv4")
 
84
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="HDA_NunDress.pt", token="HDA_NunDress")
85
  pipe.load_textual_inversion("broyang/hentaidigitalart_v20", weight_name="HDA_Shibari.pt", token="HDA_Shibari")
86
  pipe.to("cuda")
87
+
88
+ print("loading preprocessor")
89
+ from preprocess import Preprocessor
90
+ preprocessor = Preprocessor()
91
+ # preprocessor.load("NormalBae")
92
+
93
  print("---------------Loaded controlnet pipeline---------------")
94
+ print(f"CUDA memory allocated: {torch.cuda.max_memory_allocated(device='cuda') / 1e9:.2f} GB")
95
 
 
 
 
 
 
 
96
  def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
97
  if randomize_seed:
98
  seed = random.randint(0, MAX_SEED)
 
131
  girls = [randomize, pet_play, bondage, lab_girl, athleisure, atompunk, maid, nundress, naked_hoodie, abg, shibari2, ahegao2]
132
  prompts_nsfw = [abg, shibari2, ahegao2]
133
  prompt = f"{random.choice(girls)}"
134
+ prompt = f"boho chic"
135
  # print(f"-------------{preset}-------------")
136
  else:
137
  prompt = f"Photo from Pinterest of {prompt} {interior}"
 
148
  "prompt": "Minimalist interior design, clean lines, neutral colors, uncluttered space, functional furniture, lots of natural light"
149
  },
150
  {
151
+ "name": "Boho",
152
  "prompt": "Bohemian chic interior, eclectic mix of patterns and textures, vintage furniture, plants, woven textiles, warm earthy colors"
153
  },
154
  {
 
212
  if style_name in styles:
213
  p = styles.get(style_name, "boho chic")
214
  return p
215
+
216
+
217
  css = """
218
+ h1 {
219
  text-align: center;
220
+ display:block;
 
 
 
 
221
  }
222
+ h2 {
223
+ text-align: center;
224
+ display:block;
 
 
 
 
 
 
 
 
 
225
  }
226
+ h3 {
227
+ text-align: center;
228
+ display:block;
 
 
 
229
  }
230
+ .gradio-container{max-width: 1200px !important}
231
+ footer {visibility: hidden}
232
  """
233
  with gr.Blocks(theme="bethecloud/storj_theme", css=css) as demo:
234
  #############################################################################
235
+ with gr.Row():
236
  with gr.Accordion("Advanced options", open=show_options, visible=show_options):
237
  num_images = gr.Slider(
238
  label="Images", minimum=1, maximum=4, value=1, step=1
 
261
  randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
262
  a_prompt = gr.Textbox(
263
  label="Additional prompt",
264
+ value = "design-style interior designed (interior space), captured with a DSLR camera using f/10 aperture, 1/60 sec shutter speed, ISO 400, 20mm focal length, tungsten white balance"
265
  )
266
  n_prompt = gr.Textbox(
267
  label="Negative prompt",
268
  value="EasyNegativeV2, fcNeg, (badhandv4:1.4), (worst quality, low quality, bad quality, normal quality:2.0), (bad hands, missing fingers, extra fingers:2.0)",
269
  )
270
  #############################################################################
 
 
 
271
  with gr.Column():
272
  prompt = gr.Textbox(
273
+ label="Custom Prompt",
274
+ placeholder="boho chic",
275
  )
276
+ with gr.Row(visible=True):
277
+ style_selection = gr.Radio(
278
  show_label=True,
279
  container=True,
280
  interactive=True,
 
282
  value="None",
283
  label="Design Styles",
284
  )
285
+ # input image
286
+ with gr.Row(equal_height=True):
287
+ with gr.Column(scale=1, min_width=300):
288
  image = gr.Image(
289
  label="Input",
290
  sources=["upload"],
 
292
  mirror_webcam=True,
293
  format="webp",
294
  )
295
+ # run button
296
  with gr.Column():
297
+ run_button = gr.Button(value="Use this one", size="lg", visible=False)
298
+ # output image
299
+ with gr.Column(scale=1, min_width=300):
300
  result = gr.Image(
301
  label="Output",
302
  interactive=False,
303
  format="webp",
304
  show_share_button= False,
305
  )
306
+ # Use this image button
307
  with gr.Column():
308
+ use_ai_button = gr.Button(value="Use this one", size="lg", visible=False)
309
  config = [
310
  image,
311
  style_selection,
 
327
  @gr.on(triggers=[image.upload, prompt.submit, run_button.click], inputs=config, outputs=result, show_progress="minimal")
328
  def auto_process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
329
  return process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
 
 
 
 
 
330
 
 
 
 
 
 
 
 
 
 
 
 
331
  # AI Image Processing and change input
332
  @gr.on(triggers=[use_ai_button.click], inputs=config, outputs=[image, result], show_progress="minimal")
333
  def submit(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed, progress=gr.Progress(track_tqdm=True)):
 
340
  yield None, gr.update()
341
  result = process_image(image, style_selection, prompt, a_prompt, n_prompt, num_images, image_resolution, preprocess_resolution, num_steps, guidance_scale, seed)
342
  yield gr.update(), result
343
+
344
  # Turn off buttons when processing
345
  @gr.on(triggers=[image.upload, use_ai_button.click, run_button.click], inputs=None, outputs=[run_button, use_ai_button], show_progress="hidden")
346
  def turn_buttons_off():
 
351
  def turn_buttons_on():
352
  return gr.update(visible=True), gr.update(visible=True)
353
 
 
354
  @torch.inference_mode()
355
  def process_image(
356
  image,
 
364
  num_steps,
365
  guidance_scale,
366
  seed,
 
367
  ):
368
  torch.cuda.synchronize()
369
  preprocess_start = time.time()
370
  print("processing image")
371
  preprocessor.load("NormalBae")
372
+
 
373
  global compiled
374
  if not compiled:
375
  print("Not Compiled")
376
  compiled = True
377
+
378
  seed = random.randint(0, MAX_SEED)
379
  generator = torch.cuda.manual_seed(seed)
380
  control_image = preprocessor(
 
390
  negative_prompt=str(n_prompt)
391
  print(prompt)
392
  start = time.time()
393
+ with torch.cuda.amp.autocast():
394
+ results = pipe(
395
+ prompt=prompt,
396
+ negative_prompt=negative_prompt,
397
+ guidance_scale=guidance_scale,
398
+ num_images_per_prompt=num_images,
399
+ num_inference_steps=num_steps,
400
+ generator=generator,
401
+ image=control_image,
402
+ ).images[0]
403
  print(f"\n-------------------------Preprocess done in: {preprocess_time:.2f} seconds-------------------------")
404
  print(f"\n-------------------------Inference done in: {time.time() - start:.2f} seconds-------------------------")
405
  results.save("temp_image.jpg")
406
  torch.cuda.synchronize()
407
  torch.cuda.empty_cache()
 
408
  return results
409
 
410
  if prod: