We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text的特征提取代码如下: import cn_clip.clip as clip from cn_clip.clip import load_from_name, available_models class TextCLIPModel(nn.Module):
def __init__(self, config, device): super().__init__() self.device = device self.model, self.preprocess = self._load_model(config) def _load_model(self, config): model, preprocess = load_from_name(config.clip_model_name, download_root=config.download_root) model.to(self.device) # 将模型移动到指定设备 model.eval() return model, preprocess def forward(self, texts): tokens = clip.tokenize(texts).to(self.device) with torch.no_grad(): text_features = self.model.encode_text(tokens) text_features /= text_features.norm(dim=-1, keepdim=True) # 归一化特征 return text_features
输入的文本txt格式: 输入的data.json格式如下: 输入的img是data文件夹: 我想问一下,这样输入数据是调用有问题,还是原始数据格式有问题
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Text的特征提取代码如下:
import cn_clip.clip as clip
from cn_clip.clip import load_from_name, available_models
class TextCLIPModel(nn.Module):
输入的文本txt格式:
输入的data.json格式如下:
输入的img是data文件夹:
我想问一下,这样输入数据是调用有问题,还是原始数据格式有问题
The text was updated successfully, but these errors were encountered: