Spaces:
Runtime error
Runtime error
Update app.py
#3
by
Manjushri
- opened
app.py
CHANGED
@@ -52,7 +52,7 @@ current_model = models[1] if is_colab else models[0]
|
|
52 |
current_model_path = current_model.path
|
53 |
|
54 |
if is_colab:
|
55 |
-
pipe = StableDiffusionPipeline.from_pretrained(current_model.path,
|
56 |
|
57 |
else: # download all models
|
58 |
print(f"{datetime.datetime.now()} Downloading vae...")
|
@@ -61,8 +61,8 @@ else: # download all models
|
|
61 |
try:
|
62 |
print(f"{datetime.datetime.now()} Downloading {model.name} model...")
|
63 |
unet = UNet2DConditionModel.from_pretrained(model.path, subfolder="unet", torch_dtype=torch.float16)
|
64 |
-
model.pipe_t2i = StableDiffusionPipeline.from_pretrained(model.path, unet=unet, vae=vae,
|
65 |
-
model.pipe_i2i = StableDiffusionImg2ImgPipeline.from_pretrained(model.path, unet=unet, vae=vae,
|
66 |
except Exception as e:
|
67 |
print(f"{datetime.datetime.now()} Failed to load model " + model.name + ": " + str(e))
|
68 |
models.remove(model)
|
@@ -152,7 +152,7 @@ def img_to_img(model_path, prompt, neg_prompt, img, strength, guidance, steps, w
|
|
152 |
current_model_path = model_path
|
153 |
|
154 |
if is_colab or current_model == custom_model:
|
155 |
-
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(current_model_path,
|
156 |
else:
|
157 |
pipe = pipe.to("cpu")
|
158 |
pipe = current_model.pipe_i2i
|
|
|
52 |
current_model_path = current_model.path
|
53 |
|
54 |
if is_colab:
|
55 |
+
pipe = StableDiffusionPipeline.from_pretrained(current_model.path, scheduler=scheduler, safety_checker=lambda images, clip_input: (images, False)) #add torch_dtype=torch.float16 for GPU
|
56 |
|
57 |
else: # download all models
|
58 |
print(f"{datetime.datetime.now()} Downloading vae...")
|
|
|
61 |
try:
|
62 |
print(f"{datetime.datetime.now()} Downloading {model.name} model...")
|
63 |
unet = UNet2DConditionModel.from_pretrained(model.path, subfolder="unet", torch_dtype=torch.float16)
|
64 |
+
model.pipe_t2i = StableDiffusionPipeline.from_pretrained(model.path, unet=unet, vae=vae, scheduler=scheduler)
|
65 |
+
model.pipe_i2i = StableDiffusionImg2ImgPipeline.from_pretrained(model.path, unet=unet, vae=vae, scheduler=scheduler) #I could add another If/Else if you want so it works with both CPU and GPU...
|
66 |
except Exception as e:
|
67 |
print(f"{datetime.datetime.now()} Failed to load model " + model.name + ": " + str(e))
|
68 |
models.remove(model)
|
|
|
152 |
current_model_path = model_path
|
153 |
|
154 |
if is_colab or current_model == custom_model:
|
155 |
+
pipe = StableDiffusionImg2ImgPipeline.from_pretrained(current_model_path, scheduler=scheduler, safety_checker=lambda images, clip_input: (images, False)) #removed another torch_dtype=torch.float16
|
156 |
else:
|
157 |
pipe = pipe.to("cpu")
|
158 |
pipe = current_model.pipe_i2i
|