wyysf commited on
Commit
2711cda
1 Parent(s): 9dd707f

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +7 -3
gradio_app.py CHANGED
@@ -100,7 +100,7 @@ imgaedream_pipeline = None
100
 
101
  @spaces.GPU
102
  def gen_mvimg(
103
- mvimg_model, image, seed, guidance_scale, step, text, neg_text, elevation,
104
  ):
105
  if seed == 0:
106
  seed = np.random.randint(1, 65535)
@@ -108,6 +108,8 @@ def gen_mvimg(
108
  if mvimg_model == "CRM":
109
  global crm_pipeline
110
  crm_pipeline.set_seed(seed)
 
 
111
  mv_imgs = crm_pipeline(
112
  image,
113
  scale=guidance_scale,
@@ -117,6 +119,8 @@ def gen_mvimg(
117
 
118
  elif mvimg_model == "ImageDream":
119
  global imagedream_pipeline, generator
 
 
120
  image = np.array(image).astype(np.float32) / 255.0
121
  image = image[..., :3] * image[..., 3:4] + (1 - image[..., 3:4])
122
  mv_imgs = imagedream_pipeline(
@@ -343,7 +347,7 @@ if __name__=="__main__":
343
  outputs=[image_input]
344
  ).success(
345
  fn=gen_mvimg,
346
- inputs=[mvimg_model, image_input, seed, mvimg_guidance_scale, mvimg_steps, text, neg_text, elevation],
347
  outputs=[view_front, view_right, view_back, view_left]
348
  ).success(
349
  fn=image2mesh,
@@ -351,7 +355,7 @@ if __name__=="__main__":
351
  outputs=outputs,
352
  api_name="generate_img2obj")
353
  run_mv_btn.click(fn=gen_mvimg,
354
- inputs=[mvimg_model, image_input, seed, mvimg_guidance_scale, mvimg_steps, text, neg_text, elevation],
355
  outputs=[view_front, view_right, view_back, view_left]
356
  )
357
  run_3d_btn.click(fn=image2mesh,
 
100
 
101
  @spaces.GPU
102
  def gen_mvimg(
103
+ mvimg_model, image, seed, guidance_scale, step, text, neg_text, elevation, backgroud_color
104
  ):
105
  if seed == 0:
106
  seed = np.random.randint(1, 65535)
 
108
  if mvimg_model == "CRM":
109
  global crm_pipeline
110
  crm_pipeline.set_seed(seed)
111
+ background = Image.new("RGBA", image.size, (127, 127, 127))
112
+ image = Image.alpha_composite(background, image)
113
  mv_imgs = crm_pipeline(
114
  image,
115
  scale=guidance_scale,
 
119
 
120
  elif mvimg_model == "ImageDream":
121
  global imagedream_pipeline, generator
122
+ background = Image.new("RGBA", image.size, backgroud_color)
123
+ image = Image.alpha_composite(background, image)
124
  image = np.array(image).astype(np.float32) / 255.0
125
  image = image[..., :3] * image[..., 3:4] + (1 - image[..., 3:4])
126
  mv_imgs = imagedream_pipeline(
 
347
  outputs=[image_input]
348
  ).success(
349
  fn=gen_mvimg,
350
+ inputs=[mvimg_model, image_input, seed, mvimg_guidance_scale, mvimg_steps, text, neg_text, elevation, backgroud_color],
351
  outputs=[view_front, view_right, view_back, view_left]
352
  ).success(
353
  fn=image2mesh,
 
355
  outputs=outputs,
356
  api_name="generate_img2obj")
357
  run_mv_btn.click(fn=gen_mvimg,
358
+ inputs=[mvimg_model, image_input, seed, mvimg_guidance_scale, mvimg_steps, text, neg_text, elevation, backgroud_color],
359
  outputs=[view_front, view_right, view_back, view_left]
360
  )
361
  run_3d_btn.click(fn=image2mesh,