mboss commited on
Commit
b78c974
·
1 Parent(s): 8aebc64

Add debug messages, switch to non-gpu rembg

Browse files
Files changed (2) hide show
  1. marble.py +13 -4
  2. requirements.txt +1 -1
marble.py CHANGED
@@ -227,12 +227,13 @@ def run_parametric_control(
227
  texture_image: Image.Image = None,
228
  num_inference_steps: int = 30,
229
  seed: int = 42,
230
- depth_map: Image.Image = None,
231
- mask: Image.Image = None,
232
  ) -> Image.Image:
233
  """Run parametric control with metallic and roughness adjustments."""
234
  # Get depth map
235
  if depth_map is None:
 
236
  model, processor = get_dpt_model()
237
  depth_map = run_dpt_depth(target_image, model, processor)
238
  else:
@@ -240,16 +241,19 @@ def run_parametric_control(
240
 
241
  # Prepare mask and init image
242
  if mask is None:
 
243
  mask = prepare_mask(target_image)
244
  else:
245
  mask = mask.resize((1024, 1024))
246
 
 
247
  if texture_image is None:
248
  texture_image = target_image
249
 
250
  init_img = prepare_init_image(target_image, mask)
251
 
252
  # Generate edit
 
253
  images = ip_model.generate_parametric_edits(
254
  texture_image,
255
  image=init_img,
@@ -274,12 +278,13 @@ def run_blend(
274
  edit_strength: float = 0.0,
275
  num_inference_steps: int = 20,
276
  seed: int = 1,
277
- depth_map: Image.Image = None,
278
- mask: Image.Image = None,
279
  ) -> Image.Image:
280
  """Run blending between two texture images."""
281
  # Get depth map
282
  if depth_map is None:
 
283
  model, processor = get_dpt_model()
284
  depth_map = run_dpt_depth(target_image, model, processor)
285
  else:
@@ -287,12 +292,16 @@ def run_blend(
287
 
288
  # Prepare mask and init image
289
  if mask is None:
 
290
  mask = prepare_mask(target_image)
291
  else:
292
  mask = mask.resize((1024, 1024))
 
 
293
  init_img = prepare_init_image(target_image, mask)
294
 
295
  # Generate edit
 
296
  images = ip_model.generate_edit(
297
  start_image=texture_image1,
298
  pil_image=texture_image1,
 
227
  texture_image: Image.Image = None,
228
  num_inference_steps: int = 30,
229
  seed: int = 42,
230
+ depth_map: Optional[Image.Image] = None,
231
+ mask: Optional[Image.Image] = None,
232
  ) -> Image.Image:
233
  """Run parametric control with metallic and roughness adjustments."""
234
  # Get depth map
235
  if depth_map is None:
236
+ print("No depth map provided, running DPT depth estimation")
237
  model, processor = get_dpt_model()
238
  depth_map = run_dpt_depth(target_image, model, processor)
239
  else:
 
241
 
242
  # Prepare mask and init image
243
  if mask is None:
244
+ print("No mask provided, preparing mask")
245
  mask = prepare_mask(target_image)
246
  else:
247
  mask = mask.resize((1024, 1024))
248
 
249
+ print("Preparing initial image")
250
  if texture_image is None:
251
  texture_image = target_image
252
 
253
  init_img = prepare_init_image(target_image, mask)
254
 
255
  # Generate edit
256
+ print("Generating parametric edit")
257
  images = ip_model.generate_parametric_edits(
258
  texture_image,
259
  image=init_img,
 
278
  edit_strength: float = 0.0,
279
  num_inference_steps: int = 20,
280
  seed: int = 1,
281
+ depth_map: Optional[Image.Image] = None,
282
+ mask: Optional[Image.Image] = None,
283
  ) -> Image.Image:
284
  """Run blending between two texture images."""
285
  # Get depth map
286
  if depth_map is None:
287
+ print("No depth map provided, running DPT depth estimation")
288
  model, processor = get_dpt_model()
289
  depth_map = run_dpt_depth(target_image, model, processor)
290
  else:
 
292
 
293
  # Prepare mask and init image
294
  if mask is None:
295
+ print("No mask provided, preparing mask")
296
  mask = prepare_mask(target_image)
297
  else:
298
  mask = mask.resize((1024, 1024))
299
+
300
+ print("Preparing initial image")
301
  init_img = prepare_init_image(target_image, mask)
302
 
303
  # Generate edit
304
+ print("Generating edit")
305
  images = ip_model.generate_edit(
306
  start_image=texture_image1,
307
  pil_image=texture_image1,
requirements.txt CHANGED
@@ -1,5 +1,5 @@
1
  diffusers==0.30
2
- rembg[gpu]
3
  einops==0.7.0
4
  transformers==4.27.4
5
  opencv-python==4.7.0.68
 
1
  diffusers==0.30
2
+ rembg
3
  einops==0.7.0
4
  transformers==4.27.4
5
  opencv-python==4.7.0.68