Huiwenshi commited on
Commit
1c05349
1 Parent(s): ff50c26

Upload app_hg.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app_hg.py +7 -8
app_hg.py CHANGED
@@ -174,13 +174,13 @@ example_ts = get_example_txt_list()
174
  # initial models
175
  ################################################################
176
 
177
- worker_xbg = Removebg()
178
  print(f"loading {args.text2image_path}")
179
  worker_t2i = Text2Image(
180
  pretrain = args.text2image_path,
181
  device = args.device,
182
  save_memory = args.save_memory
183
  )
 
184
  worker_i2v = Image2Views(
185
  use_lite = args.use_lite,
186
  device = args.device,
@@ -193,15 +193,15 @@ worker_v23 = Views2Mesh(
193
  device = args.device,
194
  save_memory = args.save_memory
195
  )
196
- worker_gif = GifRenderer(args.device)
197
 
198
 
199
  if BAKE_AVAILEBLE:
200
- worker_baker = MeshBaker()
201
 
202
 
203
  ### functional modules
204
- @spaces.GPU(duration=180)
205
  def stage_0_t2i(text, image, seed, step):
206
  os.makedirs('./outputs/app_output', exist_ok=True)
207
  exists = set(int(_) for _ in os.listdir('./outputs/app_output') if not _.startswith("."))
@@ -226,7 +226,6 @@ def stage_0_t2i(text, image, seed, step):
226
  dst = worker_xbg(image, save_folder)
227
  return dst, save_folder
228
 
229
- @spaces.GPU(duration=180)
230
  def stage_1_xbg(image, save_folder, force_remove):
231
  if isinstance(image, str):
232
  image = Image.open(image)
@@ -235,7 +234,7 @@ def stage_1_xbg(image, save_folder, force_remove):
235
  rgba.save(dst)
236
  return dst
237
 
238
- @spaces.GPU(duration=180)
239
  def stage_2_i2v(image, seed, step, save_folder):
240
  if isinstance(image, str):
241
  image = Image.open(image)
@@ -250,7 +249,7 @@ def stage_2_i2v(image, seed, step, save_folder):
250
  show_img = Image.fromarray(show_img)
251
  return views_img, cond_img, show_img
252
 
253
- @spaces.GPU(duration=180)
254
  def stage_3_v23(
255
  views_pil,
256
  cond_pil,
@@ -273,7 +272,7 @@ def stage_3_v23(
273
  obj_dst = save_folder + '/mesh_vertex_colors.obj' # gradio just only can show vertex shading
274
  return obj_dst, glb_dst
275
 
276
- @spaces.GPU(duration=180)
277
  def stage_3p_baking(save_folder, color, bake):
278
  if color == "texture" and bake:
279
  obj_dst = worker_baker(save_folder)
 
174
  # initial models
175
  ################################################################
176
 
 
177
  print(f"loading {args.text2image_path}")
178
  worker_t2i = Text2Image(
179
  pretrain = args.text2image_path,
180
  device = args.device,
181
  save_memory = args.save_memory
182
  )
183
+ worker_xbg = Removebg()
184
  worker_i2v = Image2Views(
185
  use_lite = args.use_lite,
186
  device = args.device,
 
193
  device = args.device,
194
  save_memory = args.save_memory
195
  )
196
+ worker_gif = GifRenderer(device=args.device)
197
 
198
 
199
  if BAKE_AVAILEBLE:
200
+ worker_baker = MeshBaker(device=args.device)
201
 
202
 
203
  ### functional modules
204
+ @spaces.GPU
205
  def stage_0_t2i(text, image, seed, step):
206
  os.makedirs('./outputs/app_output', exist_ok=True)
207
  exists = set(int(_) for _ in os.listdir('./outputs/app_output') if not _.startswith("."))
 
226
  dst = worker_xbg(image, save_folder)
227
  return dst, save_folder
228
 
 
229
  def stage_1_xbg(image, save_folder, force_remove):
230
  if isinstance(image, str):
231
  image = Image.open(image)
 
234
  rgba.save(dst)
235
  return dst
236
 
237
+ @spaces.GPU
238
  def stage_2_i2v(image, seed, step, save_folder):
239
  if isinstance(image, str):
240
  image = Image.open(image)
 
249
  show_img = Image.fromarray(show_img)
250
  return views_img, cond_img, show_img
251
 
252
+ @spaces.GPU(duration=120)
253
  def stage_3_v23(
254
  views_pil,
255
  cond_pil,
 
272
  obj_dst = save_folder + '/mesh_vertex_colors.obj' # gradio just only can show vertex shading
273
  return obj_dst, glb_dst
274
 
275
+ @spaces.GPU
276
  def stage_3p_baking(save_folder, color, bake):
277
  if color == "texture" and bake:
278
  obj_dst = worker_baker(save_folder)