xinjie.wang commited on
Commit
9dd1694
·
1 Parent(s): f7ed567
Files changed (1) hide show
  1. app.py +36 -36
app.py CHANGED
@@ -35,21 +35,21 @@ TMP_DIR = os.path.join(
35
  )
36
  os.makedirs(TMP_DIR, exist_ok=True)
37
 
38
- RBG_REMOVER = RembgRemover()
39
- SAM_PREDICTOR = SAMPredictor(model_type="vit_h")
40
- DELIGHT = DelightingModel()
41
- IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
42
- PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
43
- "JeffreyXiang/TRELLIS-image-large"
44
- )
45
- # PIPELINE.cuda()
46
 
47
- IMAGE_BUFFER = {}
48
- SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
49
- GEO_CHECKER = MeshGeoChecker(GPT_CLIENT)
50
- AESTHETIC_CHECKER = ImageAestheticChecker()
51
- CHECKERS = [GEO_CHECKER, SEG_CHECKER, AESTHETIC_CHECKER]
52
- URDF_CONVERTOR = URDFGenerator(GPT_CLIENT, render_view_num=4)
53
 
54
 
55
  def start_session(req: gr.Request) -> None:
@@ -233,11 +233,11 @@ with gr.Blocks(
233
  )
234
  ],
235
  inputs=[image_prompt],
236
- fn=partial(
237
- preprocess_image_fn,
238
- model=RBG_REMOVER,
239
- buffer=IMAGE_BUFFER,
240
- ),
241
  outputs=[image_prompt],
242
  run_on_click=True,
243
  examples_per_page=32,
@@ -253,11 +253,11 @@ with gr.Blocks(
253
  )
254
  ],
255
  inputs=[image_prompt_sam],
256
- fn=partial(
257
- preprocess_sam_image_fn,
258
- buffer=IMAGE_BUFFER,
259
- model=SAM_PREDICTOR,
260
- ),
261
  outputs=[image_prompt_sam],
262
  run_on_click=True,
263
  examples_per_page=32,
@@ -305,7 +305,7 @@ with gr.Blocks(
305
  )
306
 
307
  image_prompt.upload(
308
- partial(preprocess_image_fn, model=RBG_REMOVER, buffer=IMAGE_BUFFER),
309
  inputs=[image_prompt],
310
  outputs=[image_prompt],
311
  )
@@ -354,9 +354,9 @@ with gr.Blocks(
354
  )
355
 
356
  image_prompt_sam.upload(
357
- partial(
358
- preprocess_sam_image_fn, buffer=IMAGE_BUFFER, model=SAM_PREDICTOR
359
- ),
360
  inputs=[image_prompt_sam],
361
  outputs=[image_prompt_sam],
362
  )
@@ -407,7 +407,7 @@ with gr.Blocks(
407
  image_prompt_sam,
408
  selected_points,
409
  fg_bg_radio,
410
- gr.State(lambda: SAM_PREDICTOR),
411
  ],
412
  [image_mask_sam, image_seg_sam],
413
  )
@@ -430,8 +430,8 @@ with gr.Blocks(
430
  ss_sampling_steps,
431
  slat_guidance_strength,
432
  slat_sampling_steps,
433
- gr.State(lambda: IMAGE_BUFFER),
434
- gr.State(lambda: PIPELINE),
435
  gr.State(lambda: TMP_DIR),
436
  image_seg_sam,
437
  is_samimage,
@@ -448,8 +448,8 @@ with gr.Blocks(
448
  output_buf,
449
  project_delight,
450
  gr.State(lambda: TMP_DIR),
451
- gr.State(lambda: DELIGHT),
452
- gr.State(lambda: IMAGESR_MODEL),
453
  ],
454
  outputs=[
455
  model_output_mesh,
@@ -472,9 +472,9 @@ with gr.Blocks(
472
  mass_range_text,
473
  asset_version_text,
474
  gr.State(lambda: TMP_DIR),
475
- gr.State(lambda: URDF_CONVERTOR),
476
- gr.State(lambda: IMAGE_BUFFER),
477
- gr.State(lambda: CHECKERS),
478
  ],
479
  outputs=[
480
  download_urdf,
 
35
  )
36
  os.makedirs(TMP_DIR, exist_ok=True)
37
 
38
+ # RBG_REMOVER = RembgRemover()
39
+ # SAM_PREDICTOR = SAMPredictor(model_type="vit_h")
40
+ # DELIGHT = DelightingModel()
41
+ # IMAGESR_MODEL = ImageRealESRGAN(outscale=4)
42
+ # PIPELINE = TrellisImageTo3DPipeline.from_pretrained(
43
+ # "JeffreyXiang/TRELLIS-image-large"
44
+ # )
45
+ # # PIPELINE.cuda()
46
 
47
+ # IMAGE_BUFFER = {}
48
+ # SEG_CHECKER = ImageSegChecker(GPT_CLIENT)
49
+ # GEO_CHECKER = MeshGeoChecker(GPT_CLIENT)
50
+ # AESTHETIC_CHECKER = ImageAestheticChecker()
51
+ # CHECKERS = [GEO_CHECKER, SEG_CHECKER, AESTHETIC_CHECKER]
52
+ # URDF_CONVERTOR = URDFGenerator(GPT_CLIENT, render_view_num=4)
53
 
54
 
55
  def start_session(req: gr.Request) -> None:
 
233
  )
234
  ],
235
  inputs=[image_prompt],
236
+ # fn=partial(
237
+ # preprocess_image_fn,
238
+ # model=RBG_REMOVER,
239
+ # buffer=IMAGE_BUFFER,
240
+ # ),
241
  outputs=[image_prompt],
242
  run_on_click=True,
243
  examples_per_page=32,
 
253
  )
254
  ],
255
  inputs=[image_prompt_sam],
256
+ # fn=partial(
257
+ # preprocess_sam_image_fn,
258
+ # buffer=IMAGE_BUFFER,
259
+ # model=SAM_PREDICTOR,
260
+ # ),
261
  outputs=[image_prompt_sam],
262
  run_on_click=True,
263
  examples_per_page=32,
 
305
  )
306
 
307
  image_prompt.upload(
308
+ # partial(preprocess_image_fn, model=RBG_REMOVER, buffer=IMAGE_BUFFER),
309
  inputs=[image_prompt],
310
  outputs=[image_prompt],
311
  )
 
354
  )
355
 
356
  image_prompt_sam.upload(
357
+ # partial(
358
+ # preprocess_sam_image_fn, buffer=IMAGE_BUFFER, model=SAM_PREDICTOR
359
+ # ),
360
  inputs=[image_prompt_sam],
361
  outputs=[image_prompt_sam],
362
  )
 
407
  image_prompt_sam,
408
  selected_points,
409
  fg_bg_radio,
410
+ # gr.State(lambda: SAM_PREDICTOR),
411
  ],
412
  [image_mask_sam, image_seg_sam],
413
  )
 
430
  ss_sampling_steps,
431
  slat_guidance_strength,
432
  slat_sampling_steps,
433
+ # gr.State(lambda: IMAGE_BUFFER),
434
+ # gr.State(lambda: PIPELINE),
435
  gr.State(lambda: TMP_DIR),
436
  image_seg_sam,
437
  is_samimage,
 
448
  output_buf,
449
  project_delight,
450
  gr.State(lambda: TMP_DIR),
451
+ # gr.State(lambda: DELIGHT),
452
+ # gr.State(lambda: IMAGESR_MODEL),
453
  ],
454
  outputs=[
455
  model_output_mesh,
 
472
  mass_range_text,
473
  asset_version_text,
474
  gr.State(lambda: TMP_DIR),
475
+ # gr.State(lambda: URDF_CONVERTOR),
476
+ # gr.State(lambda: IMAGE_BUFFER),
477
+ # gr.State(lambda: CHECKERS),
478
  ],
479
  outputs=[
480
  download_urdf,