Update app.py
Browse files
app.py
CHANGED
@@ -29,8 +29,8 @@ def pref_inpainting(image,
|
|
29 |
|
30 |
pipe = AutoPipelineForInpainting.from_pretrained(
|
31 |
'/data1/kendong/joint-rl-diffusion/alignment_log/exp_reward_group_regression_all_1w_1.6boundary/iteration_2560', num_inference_steps=steps)
|
32 |
-
|
33 |
-
pipe = pipe.to(
|
34 |
|
35 |
|
36 |
color, mask = outpainting_generator_rectangle(image, box_width_ratio/100, mask_random_start)
|
@@ -42,15 +42,15 @@ def pref_inpainting(image,
|
|
42 |
mask_[mask < 125] = 0
|
43 |
mask_[mask >= 125] = 1
|
44 |
|
45 |
-
color = torch.from_numpy(color).to(
|
46 |
-
mask = torch.from_numpy(mask).to(
|
47 |
|
48 |
|
49 |
color, mask = transform(color), transform(mask)
|
50 |
res = pipe(prompt='', image=color, mask_image=mask, eta=config.eta).images[0]
|
51 |
|
52 |
|
53 |
-
res.save(os.path.join('./', 'test.png'))
|
54 |
|
55 |
return color, res
|
56 |
|
|
|
29 |
|
30 |
pipe = AutoPipelineForInpainting.from_pretrained(
|
31 |
'/data1/kendong/joint-rl-diffusion/alignment_log/exp_reward_group_regression_all_1w_1.6boundary/iteration_2560', num_inference_steps=steps)
|
32 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
33 |
+
pipe = pipe.to(device)
|
34 |
|
35 |
|
36 |
color, mask = outpainting_generator_rectangle(image, box_width_ratio/100, mask_random_start)
|
|
|
42 |
mask_[mask < 125] = 0
|
43 |
mask_[mask >= 125] = 1
|
44 |
|
45 |
+
color = torch.from_numpy(color).to(device)
|
46 |
+
mask = torch.from_numpy(mask).to(device)
|
47 |
|
48 |
|
49 |
color, mask = transform(color), transform(mask)
|
50 |
res = pipe(prompt='', image=color, mask_image=mask, eta=config.eta).images[0]
|
51 |
|
52 |
|
53 |
+
# res.save(os.path.join('./', 'test.png'))
|
54 |
|
55 |
return color, res
|
56 |
|