xichenhku commited on
Commit
46e3758
1 Parent(s): 5acf1bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -24,7 +24,7 @@ from modelscope.hub.snapshot_download import snapshot_download as ms_snapshot_do
24
  import spaces
25
 
26
 
27
- '''
28
  sd_dir = ms_snapshot_download('xichen/cleansd', cache_dir='./modelscope')
29
  print('=== Pretrained SD weights downloaded ===')
30
  model_dir = ms_snapshot_download('xichen/MimicBrush', cache_dir='./modelscope')
@@ -62,7 +62,7 @@ image_encoder_path = val_configs.model_path.image_encoder_path
62
  ref_model_path = val_configs.model_path.pretrained_reference_path
63
  mimicbrush_ckpt = val_configs.model_path.mimicbrush_ckpt_path
64
  device = "cuda"
65
- '''
66
 
67
 
68
  def pad_img_to_square(original_image, is_mask=False):
@@ -148,7 +148,7 @@ def vis_mask(image, mask):
148
  return image
149
 
150
 
151
- '''
152
  noise_scheduler = DDIMScheduler(
153
  num_train_timesteps=1000,
154
  beta_start=0.00085,
@@ -177,7 +177,7 @@ depth_guider = DepthGuider()
177
  referencenet = ReferenceNet.from_pretrained(ref_model_path, subfolder="unet").to(dtype=torch.float16)
178
  mimicbrush_model = MimicBrush_RefNet(pipe, image_encoder_path, mimicbrush_ckpt, depth_anything_model, depth_guider, referencenet, device)
179
  mask_processor = VaeImageProcessor(vae_scale_factor=1, do_normalize=False, do_binarize=True, do_convert_grayscale=True)
180
- '''
181
  @spaces.GPU
182
  def infer_single(ref_image, target_image, target_mask, seed = -1, num_inference_steps=50, guidance_scale = 5, enable_shape_control = False):
183
  #return ref_image
@@ -185,8 +185,7 @@ def infer_single(ref_image, target_image, target_mask, seed = -1, num_inference_
185
  mask: 0/1 1-channel np.array
186
  image: rgb np.array
187
  """
188
- return ref_image, ref_image
189
- """
190
  ref_image = ref_image.astype(np.uint8)
191
  target_image = target_image.astype(np.uint8)
192
  target_mask = target_mask .astype(np.uint8)
@@ -229,7 +228,7 @@ def infer_single(ref_image, target_image, target_mask, seed = -1, num_inference_
229
  pred = pred[0]
230
  pred = np.array(pred).astype(np.uint8)
231
  return pred, depth_pred.astype(np.uint8)
232
- """
233
 
234
 
235
  def inference_single_image(ref_image,
 
24
  import spaces
25
 
26
 
27
+
28
  sd_dir = ms_snapshot_download('xichen/cleansd', cache_dir='./modelscope')
29
  print('=== Pretrained SD weights downloaded ===')
30
  model_dir = ms_snapshot_download('xichen/MimicBrush', cache_dir='./modelscope')
 
62
  ref_model_path = val_configs.model_path.pretrained_reference_path
63
  mimicbrush_ckpt = val_configs.model_path.mimicbrush_ckpt_path
64
  device = "cuda"
65
+
66
 
67
 
68
  def pad_img_to_square(original_image, is_mask=False):
 
148
  return image
149
 
150
 
151
+
152
  noise_scheduler = DDIMScheduler(
153
  num_train_timesteps=1000,
154
  beta_start=0.00085,
 
177
  referencenet = ReferenceNet.from_pretrained(ref_model_path, subfolder="unet").to(dtype=torch.float16)
178
  mimicbrush_model = MimicBrush_RefNet(pipe, image_encoder_path, mimicbrush_ckpt, depth_anything_model, depth_guider, referencenet, device)
179
  mask_processor = VaeImageProcessor(vae_scale_factor=1, do_normalize=False, do_binarize=True, do_convert_grayscale=True)
180
+
181
  @spaces.GPU
182
  def infer_single(ref_image, target_image, target_mask, seed = -1, num_inference_steps=50, guidance_scale = 5, enable_shape_control = False):
183
  #return ref_image
 
185
  mask: 0/1 1-channel np.array
186
  image: rgb np.array
187
  """
188
+
 
189
  ref_image = ref_image.astype(np.uint8)
190
  target_image = target_image.astype(np.uint8)
191
  target_mask = target_mask .astype(np.uint8)
 
228
  pred = pred[0]
229
  pred = np.array(pred).astype(np.uint8)
230
  return pred, depth_pred.astype(np.uint8)
231
+
232
 
233
 
234
  def inference_single_image(ref_image,