kd5678 commited on
Commit
cb9a173
1 Parent(s): 23b9c47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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("cuda")
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("cuda")
46
- mask = torch.from_numpy(mask).to("cuda")
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