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

Method __init__

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

Source from the content-addressed store, hash-verified

195
196class CustomCLIP(nn.Module):
197 def __init__(self, cfg, classnames, clip_model):
198 super().__init__()
199 self.n_cls = len(classnames)
200 self.prompt_learner = PromptLearner(cfg, classnames, clip_model)
201 self.tokenized_prompts = self.prompt_learner.tokenized_prompts
202 self.image_encoder = clip_model.visual
203 self.text_encoder = TextEncoder(clip_model)
204 self.logit_scale = clip_model.logit_scale
205 self.dtype = clip_model.dtype
206 self.device = torch.device("cuda:0")
207 self.device1 = torch.device("cuda")
208 self.N = cfg.TRAINER.PLOT.N
209 self.dataset = cfg.DATASET.NAME
210 self.use_uniform = True
211 self.eps = 0.1
212 self.max_iter = 100
213
214 def Sinkhorn(self, K, u, v):
215 r = torch.ones_like(u)

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 2

PromptLearnerClass · 0.70
TextEncoderClass · 0.70

Tested by

no test coverage detected