Skip to content

Instantly share code, notes, and snippets.

andrea137 /
Created March 1, 2023 11:55 — forked from andrewjong/
PyTorch Image File Paths With Dataset Dataloader
import torch
from torchvision import datasets
class ImageFolderWithPaths(datasets.ImageFolder):
"""Custom dataset that includes image file paths. Extends
# override the __getitem__ method. this is the method that dataloader calls
def __getitem__(self, index):
andrea137 /
Created November 8, 2018 10:45
A simple script to export all the conda/Anaconda environments at once. Useful for example to backup or to move conda/Anaconda from one directory to another (
#!/usr/bin/env bash
. $HOME/miniconda3/etc/profile.d/
mkdir conda_env_backups
cd conda_env_backups
conda info --envs | awk 'NR>2 {print $1}' > tmp_env_names
while read in; do
conda activate "$in"
conda env export > $in.yml
conda deactivate
done < tmp_env_names