huzefa11 commited on
Commit
21f5a60
·
verified ·
1 Parent(s): 054dd0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -18,7 +18,7 @@ if is_torch2_available():
18
  AttnProcessor2_0 as AttnProcessor
19
  # from gradio_utils import SpatialAttnProcessor2_0
20
  else:
21
- from gradio_utils import AttnProcessor
22
 
23
  import diffusers
24
  from diffusers import StableDiffusionXLPipeline
@@ -40,7 +40,7 @@ DEFAULT_STYLE_NAME = "Japanese Anime"
40
  global models_dict
41
  use_va = True
42
  models_dict = {
43
- "Juggernaut": "RunDiffusion/Juggernaut-XL-v8",
44
  # "RealVision": "SG161222/RealVisXL_V4.0" ,
45
  "SDXL":"stabilityai/stable-diffusion-xl-base-1.0" ,
46
  # "Unstable": "stablediffusionapi/sdxl-unstable-diffusers-y"
@@ -435,7 +435,7 @@ use_safetensors= False
435
  # # pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
436
  # pipe1.scheduler.set_timesteps(50)
437
  ###
438
- pipe2 = PhotoMakerStableDiffusionXLPipeline.from_pretrained(
439
  models_dict["Juggernaut"], torch_dtype=torch.float16, use_safetensors=use_safetensors)
440
  pipe2 = pipe2.to("cpu")
441
  pipe2.load_photomaker_adapter(
@@ -446,7 +446,7 @@ pipe2.load_photomaker_adapter(
446
  )
447
  pipe2 = pipe2.to("cpu")
448
  pipe2.enable_freeu(s1=0.6, s2=0.4, b1=1.1, b2=1.2)
449
- pipe2.fuse_lora()
450
 
451
  pipe4 = PhotoMakerStableDiffusionXLPipeline.from_pretrained(
452
  models_dict["SDXL"], torch_dtype=torch.float16, use_safetensors=True)
@@ -520,7 +520,7 @@ def process_generation(_sd_type,_model_type,_upload_images, _num_steps,style_nam
520
  num_steps =_num_steps
521
  use_safe_tensor = True
522
  if style_name == "(No style)":
523
- sd_model_path = models_dict["Juggernaut"]
524
  if _model_type == "original":
525
  pipe = StableDiffusionXLPipeline.from_pretrained(sd_model_path, torch_dtype=torch.float16)
526
  pipe = pipe.to(device)
@@ -529,7 +529,7 @@ def process_generation(_sd_type,_model_type,_upload_images, _num_steps,style_nam
529
  # pipe.scheduler.set_timesteps(50)
530
  set_attention_processor(pipe.unet,id_length_,is_ipadapter = False)
531
  elif _model_type == "Photomaker":
532
- if _sd_type != "Juggernaut" and style_name != "(No style)":
533
  pipe = pipe2.to(device)
534
  pipe.id_encoder.to(device)
535
  set_attention_processor(pipe.unet,id_length_,is_ipadapter = False)
 
18
  AttnProcessor2_0 as AttnProcessor
19
  # from gradio_utils import SpatialAttnProcessor2_0
20
  else:
21
+ from gradio_utils import AttnProcessor
22
 
23
  import diffusers
24
  from diffusers import StableDiffusionXLPipeline
 
40
  global models_dict
41
  use_va = True
42
  models_dict = {
43
+ # "Juggernaut": "RunDiffusion/Juggernaut-XL-v8",
44
  # "RealVision": "SG161222/RealVisXL_V4.0" ,
45
  "SDXL":"stabilityai/stable-diffusion-xl-base-1.0" ,
46
  # "Unstable": "stablediffusionapi/sdxl-unstable-diffusers-y"
 
435
  # # pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config)
436
  # pipe1.scheduler.set_timesteps(50)
437
  ###
438
+ ''''pipe2 = PhotoMakerStableDiffusionXLPipeline.from_pretrained(
439
  models_dict["Juggernaut"], torch_dtype=torch.float16, use_safetensors=use_safetensors)
440
  pipe2 = pipe2.to("cpu")
441
  pipe2.load_photomaker_adapter(
 
446
  )
447
  pipe2 = pipe2.to("cpu")
448
  pipe2.enable_freeu(s1=0.6, s2=0.4, b1=1.1, b2=1.2)
449
+ pipe2.fuse_lora()'''
450
 
451
  pipe4 = PhotoMakerStableDiffusionXLPipeline.from_pretrained(
452
  models_dict["SDXL"], torch_dtype=torch.float16, use_safetensors=True)
 
520
  num_steps =_num_steps
521
  use_safe_tensor = True
522
  if style_name == "(No style)":
523
+ sd_model_path = models_dict["SDXL"]
524
  if _model_type == "original":
525
  pipe = StableDiffusionXLPipeline.from_pretrained(sd_model_path, torch_dtype=torch.float16)
526
  pipe = pipe.to(device)
 
529
  # pipe.scheduler.set_timesteps(50)
530
  set_attention_processor(pipe.unet,id_length_,is_ipadapter = False)
531
  elif _model_type == "Photomaker":
532
+ if _sd_type != "SDXL" and style_name != "(No style)":
533
  pipe = pipe2.to(device)
534
  pipe.id_encoder.to(device)
535
  set_attention_processor(pipe.unet,id_length_,is_ipadapter = False)