MCPcopy Create free account
hub / github.com/aigc3d/LHM / __init__

Method __init__

engine/SegmentAPI/SAM.py:130–157  ·  view source on GitHub ↗
(
        self,
        config="sam2.1_hiera_l.yaml",
        matting_config="resnet50",
        background=(1.0, 1.0, 1.0),
        wo_supres=False,
    )

Source from the content-addressed store, hash-verified

128 self.image_predictor.model.cuda()
129
130 def __init__(
131 self,
132 config="sam2.1_hiera_l.yaml",
133 matting_config="resnet50",
134 background=(1.0, 1.0, 1.0),
135 wo_supres=False,
136 ):
137 super().__init__()
138
139 self.device = avaliable_device()
140
141 try:
142 sam2_image_model = build_sam2(config, SAM2_WEIGHT)
143 except:
144 config = os.path.join("./configs/sam2.1/", config) # sam2.1 case
145 sam2_image_model = build_sam2(config, SAM2_WEIGHT)
146
147 self.image_predictor = SAM2ImagePredictor(sam2_image_model)
148
149 self.box_prior = None
150
151 # Robust-Human-Matting
152
153 # self.matting_predictor = MattingNetwork(matting_config).eval().cuda()
154 # self.matting_predictor.load_state_dict(torch.load(MATTING_WEIGHT))
155
156 self.background = background
157 self.wo_supers = wo_supres
158
159 def clean_up(self):
160 self.tmp.cleanup()

Callers

nothing calls this directly

Calls 1

avaliable_deviceFunction · 0.70

Tested by

no test coverage detected