fix cpu problems
Browse files
app.py
CHANGED
@@ -10,12 +10,16 @@ device = "cpu"
|
|
10 |
# model_id_or_path = "runwayml/stable-diffusion-v1-5"
|
11 |
# takes too much time downloading, change to local path
|
12 |
model_path = "."
|
13 |
-
img2img_pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_path)
|
14 |
img2img_pipe = img2img_pipe.to(device)
|
15 |
|
16 |
|
17 |
-
def img2img_diff(prompt,
|
|
|
18 |
return img2img_pipe(prompt=prompt, image=img, strength=0.75, guidance_scale=7.5).images[0]
|
19 |
|
20 |
|
21 |
-
gr.Interface(fn=img2img_diff, inputs=[
|
|
|
|
|
|
|
|
10 |
# model_id_or_path = "runwayml/stable-diffusion-v1-5"
|
11 |
# takes too much time downloading, change to local path
|
12 |
model_path = "."
|
13 |
+
img2img_pipe = StableDiffusionImg2ImgPipeline.from_pretrained(model_path, torch_dtype=torch.float32)
|
14 |
img2img_pipe = img2img_pipe.to(device)
|
15 |
|
16 |
|
17 |
+
def img2img_diff(prompt, pil_img):
|
18 |
+
img = pil_img.resize((768, 512))
|
19 |
return img2img_pipe(prompt=prompt, image=img, strength=0.75, guidance_scale=7.5).images[0]
|
20 |
|
21 |
|
22 |
+
app = gr.Interface(fn=img2img_diff, inputs=[gr.Text(label="prompt text"), gr.Image(type='pil', label='draft image')],
|
23 |
+
outputs=gr.Image(type='pil'))
|
24 |
+
if __name__ == "__main__":
|
25 |
+
app.launch(debug=True)
|