fkunn1326 commited on
Commit
190548d
1 Parent(s): 96b8ba5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -42,19 +42,18 @@ last_mode = "txt2img"
42
  current_model = models[0]
43
  current_model_path = current_model.path
44
 
45
- else:
46
- print(f"{datetime.datetime.now()} Downloading vae...")
47
- vae = AutoencoderKL.from_pretrained(current_model.path, subfolder="vae")
48
- for model in models:
49
- try:
50
- print(f"{datetime.datetime.now()} Downloading {model.name} model...")
51
- unet = UNet2DConditionModel.from_pretrained(model.path, subfolder="unet")
52
- model.pipe_t2i = StableDiffusionPipeline.from_pretrained(model.path, unet=unet, vae=vae, scheduler=scheduler)
53
- model.pipe_i2i = StableDiffusionImg2ImgPipeline.from_pretrained(model.path, unet=unet, vae=vae, scheduler=scheduler)
54
- except Exception as e:
55
- print(f"{datetime.datetime.now()} Failed to load model " + model.name + ": " + str(e))
56
- models.remove(model)
57
- pipe = models[0].pipe_t2i
58
 
59
  if torch.cuda.is_available():
60
  pipe = pipe.to("cuda")
 
42
  current_model = models[0]
43
  current_model_path = current_model.path
44
 
45
+ print(f"{datetime.datetime.now()} Downloading vae...")
46
+ vae = AutoencoderKL.from_pretrained(current_model.path, subfolder="vae")
47
+ for model in models:
48
+ try:
49
+ print(f"{datetime.datetime.now()} Downloading {model.name} model...")
50
+ unet = UNet2DConditionModel.from_pretrained(model.path, subfolder="unet")
51
+ model.pipe_t2i = StableDiffusionPipeline.from_pretrained(model.path, unet=unet, vae=vae, scheduler=scheduler)
52
+ model.pipe_i2i = StableDiffusionImg2ImgPipeline.from_pretrained(model.path, unet=unet, vae=vae, scheduler=scheduler)
53
+ except Exception as e:
54
+ print(f"{datetime.datetime.now()} Failed to load model " + model.name + ": " + str(e))
55
+ models.remove(model)
56
+ pipe = models[0].pipe_t2i
 
57
 
58
  if torch.cuda.is_available():
59
  pipe = pipe.to("cuda")