๐
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
| from sshtunnel import SSHTunnelForwarder | |
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import sessionmaker | |
| from functools import wraps | |
| # secrets.py contains credentials, etc. | |
| import secrets | |
| def get_engine_for_port(port): | |
| return create_engine('postgresql://{user}:{password}@{host}:{port}/{db}'.format( |
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
| """ | |
| An implementation of the pytorch Subset that returns an instance of the original dataset with a reduced number of items. | |
| This has two benefits: | |
| - It allows to stil access the attributes of the Dataset class, such as methods, or properties. | |
| - You can use the usual python index notation with slices to chunk the dataset, rather than creating a list of indices | |
| """ | |
| class Dataset(object): | |
| def __init__(self, iterable): | |
| self.items = iterable |
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
| # I added all the imports by hand | |
| import torch | |
| from torchvision.datasets import ImageFolder | |
| from torchvision import transforms,models | |
| from torch import nn,optim | |
| # For all functions including this one, I wrote the name and docstring, and sometimes also the param names | |
| def finetune(folder, model): | |
| """fine tune pytorch model using images from folder and report results on validation set""" | |
| if not os.path.exists(folder): raise ValueError(f"{folder} does not exist") |
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 json | |
| import numpy as np | |
| from pycocotools import mask | |
| from skimage import measure | |
| ground_truth_binary_mask = np.array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
| [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], | |
| [ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], | |
| [ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], | |
| [ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0], |
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/bash | |
| # Check if the script is run with root privileges | |
| if [ "$EUID" -ne 0 ]; then | |
| echo "Please run as root" | |
| exit | |
| fi | |
| # Determine the log file based on the distribution | |
| if [ -f /var/log/auth.log ]; then |
OlderNewer