flamehaze1115 commited on
Commit
56861f3
·
verified ·
1 Parent(s): 3ccc476

Update gradio_app.py

Browse files
Files changed (1) hide show
  1. gradio_app.py +5 -8
gradio_app.py CHANGED
@@ -29,10 +29,7 @@ from mvdiffusion.pipelines.pipeline_mvdiffusion_image import MVDiffusionImagePip
29
  from diffusers import AutoencoderKL, DDPMScheduler, DDIMScheduler
30
  from einops import rearrange
31
  import numpy as np
32
-
33
-
34
-
35
-
36
 
37
  def save_image(tensor):
38
  ndarr = tensor.mul(255).add_(0.5).clamp_(0, 255).permute(1, 2, 0).to("cpu", torch.uint8).numpy()
@@ -60,10 +57,10 @@ if not hasattr(Image, 'Resampling'):
60
 
61
 
62
  def sam_init():
63
- sam_checkpoint = os.path.join(os.path.dirname(__file__), "sam_pt", "sam_vit_h_4b8939.pth")
64
- model_type = "vit_h"
65
-
66
- sam = sam_model_registry[model_type](checkpoint=sam_checkpoint).to(device=f"cuda:{_GPU_ID}")
67
  predictor = SamPredictor(sam)
68
  return predictor
69
 
 
29
  from diffusers import AutoencoderKL, DDPMScheduler, DDIMScheduler
30
  from einops import rearrange
31
  import numpy as np
32
+ from transformers import SamModel
 
 
 
33
 
34
  def save_image(tensor):
35
  ndarr = tensor.mul(255).add_(0.5).clamp_(0, 255).permute(1, 2, 0).to("cpu", torch.uint8).numpy()
 
57
 
58
 
59
  def sam_init():
60
+ # sam_checkpoint = os.path.join(os.path.dirname(__file__), "sam_pt", "sam_vit_h_4b8939.pth")
61
+ # model_type = "vit_h"
62
+ # sam = sam_model_registry[model_type](checkpoint=sam_checkpoint).to(device=f"cuda:{_GPU_ID}")
63
+ sam = SamModel.from_pretrained("facebook/sam-vit-huge").to(device=f"cuda:{_GPU_ID}")
64
  predictor = SamPredictor(sam)
65
  return predictor
66