remove and to device
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ auth_token = os.environ.get("API_TOKEN") or True
|
|
18 |
|
19 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
20 |
|
21 |
-
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-inpainting", dtype=torch.float16, revision="fp16", use_auth_token=auth_token)
|
22 |
|
23 |
transform = transforms.Compose([
|
24 |
transforms.ToTensor(),
|
@@ -35,10 +35,9 @@ def read_content(file_path: str) -> str:
|
|
35 |
return content
|
36 |
|
37 |
def predict(dict, prompt=""):
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
output = pipe(prompt = prompt, image=init_image, mask_image=mask,guidance_scale=7.5)
|
42 |
return output.images[0]
|
43 |
|
44 |
|
|
|
18 |
|
19 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
20 |
|
21 |
+
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-inpainting", dtype=torch.float16, revision="fp16", use_auth_token=auth_token).to(device)
|
22 |
|
23 |
transform = transforms.Compose([
|
24 |
transforms.ToTensor(),
|
|
|
35 |
return content
|
36 |
|
37 |
def predict(dict, prompt=""):
|
38 |
+
init_image = dict["image"].convert("RGB").resize((512, 512))
|
39 |
+
mask = dict["mask"].convert("RGB").resize((512, 512))
|
40 |
+
output = pipe(prompt = prompt, image=init_image, mask_image=mask,guidance_scale=7.5)
|
|
|
41 |
return output.images[0]
|
42 |
|
43 |
|