MCPcopy Create free account
hub / github.com/CHENGY12/PLOT / __init__

Method __init__

plot-pp/trainers/plotpp.py:178–197  ·  view source on GitHub ↗
(self, cfg, classnames, clip_model)

Source from the content-addressed store, hash-verified

176
177class CustomCLIP(nn.Module):
178 def __init__(self, cfg, classnames, clip_model):
179 super().__init__()
180 self.prompt_learner = MultiModalPromptLearner(cfg, classnames, clip_model)
181 self.tokenized_prompts = self.prompt_learner.tokenized_prompts
182 self.image_encoder = clip_model.visual
183 self.text_encoder = TextEncoder(clip_model)
184 self.logit_scale = clip_model.logit_scale
185 self.dtype = clip_model.dtype
186 self.N = cfg.TRAINER.PLOTPP.N
187 self.n_cls = len(classnames)
188 self.tradeoff = cfg.TRAINER.PLOTPP.TRADE_OFF # whether use OT
189 self.eps = 0.1
190 self.max_iter = 100
191 self.dataset = cfg.DATASET.NAME
192 if self.dataset== 'ImageNet':
193 self.device = torch.device('cuda:0')
194 self.device1 = torch.device("cuda")
195 else:
196 self.device = torch.device(cfg['DEVICE'])
197 self.device1 = torch.device("cuda")
198
199 def Sinkhorn(self, K, u, v):
200 r = torch.ones_like(u)

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 2

TextEncoderClass · 0.70

Tested by

no test coverage detected