Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import torchvision as tv | |
| class ImagesDataset(torch.utils.data.Dataset): | |
| def __init__(self, df, transform=None, | |
| loader=tv.datasets.folder.default_loader): | |
| self.df = df | |
| self.transform = transform | |
| self.loader = loader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ImagesDataset(torch.utils.data.Dataset): | |
| pass | |
| class Net(nn.Module): | |
| pass | |
| model = Net() | |
| optimizer = torch.optim.SGD(model.parameters(), lr=0.01) | |
| scheduler = lr_scheduler.StepLR(optimizer, step_size=30, gamma=0.1) | |
| criterion = torch.nn.MSELoss() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| 0: "tench, Tinca tinca", | |
| 1: "goldfish, Carassius auratus", | |
| 2: "great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias", | |
| 3: "tiger shark, Galeocerdo cuvieri", | |
| 4: "hammerhead, hammerhead shark", | |
| 5: "electric ray, crampfish, numbfish, torpedo", | |
| 6: "stingray", | |
| 7: "cock", | |
| 8: "hen", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import torchvision | |
| def get_model(): | |
| return torchvision.models.resnet18(pretrained=True) | |
| def get_pred(model): | |
| return model(torch.rand([1,3,224,224])) | |
| model = get_model() | |
| for i in range(1,10000): | |
| get_pred(model) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def make_weights_for_balanced_classes(images, nclasses): | |
| count = [0] * nclasses | |
| for item in images: | |
| count[item[1]] += 1 | |
| weight_per_class = [0.] * nclasses | |
| N = float(sum(count)) | |
| for i in range(nclasses): | |
| weight_per_class[i] = N/float(count[i]) | |
| weight = [0] * len(images) | |
| for idx, val in enumerate(images): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| if [ "$PYENV_VERSION" -ne "" ] | |
| then | |
| name=`pyenv version-name` | |
| python=`pyenv which python` | |
| else | |
| name=`basename "$VIRTUAL_ENV"` | |
| python="$VIRTUALENV/bin/python" | |
| fi |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const AWS = require('aws-sdk') | |
| const rek = new AWS.Rekognition(); | |
| var configuration = { | |
| AWSAccessKeyId: process.env.AWSAccessKeyId, | |
| AWSSecretKey: process.env.AWSSecretKey | |
| } | |
| AWS.config.update({ | |
| accessKeyId: configuration.AWSAccessKeyId, |