Skip to content

Instantly share code, notes, and snippets.

@andrea137
andrea137 / export_conda_envs.sh
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 (https://docs.anaconda.com/anaconda/user-guide/tasks/move-directory/)
#!/usr/bin/env bash
. $HOME/miniconda3/etc/profile.d/conda.sh
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
@andrea137
andrea137 / pytorch_image_folder_with_file_paths.py
Created March 1, 2023 11:55 — forked from andrewjong/pytorch_image_folder_with_file_paths.py
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
torchvision.datasets.ImageFolder
"""
# override the __getitem__ method. this is the method that dataloader calls
def __getitem__(self, index):