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
Can anyone use C # to extract features from images? Can C # extract features by executing Python code similar to the following?
model = models.resnet50(pretrained=True) model.eval() model = torch.nn.Sequential(*list(model.children())[:-1]) preprocess = transforms.Compose([ transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]), ]) def extract_features(image_path): if image_path.startswith('http://') or image_path.startswith('https://'): response = requests.get(image_path) img = Image.open(BytesIO(response.content)).convert('RGB') elif os.path.exists(image_path): img = Image.open(image_path).convert('RGB') else: raise ValueError("Invalid image path or URL.") img_tensor = preprocess(img).unsqueeze(0) with torch.no_grad(): features = model(img_tensor).numpy() return features.flatten()
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Can anyone use C # to extract features from images?
Can C # extract features by executing Python code similar to the following?
The text was updated successfully, but these errors were encountered: