Skip to content

Instantly share code, notes, and snippets.

@a-canela
a-canela / s3_client_sync_download_folder.py
Last active May 15, 2023 00:34
Directory download (sync) through boto3 supporting include-only pattern
import os
import boto3
from fnmatch import fnmatch
from botocore.config import Config
from traceback import format_exc
from multiprocessing import Process, Queue, Pipe
from concurrent.futures import ThreadPoolExecutor
class DownloadException(Exception):
@a-canela
a-canela / cubic.py
Created March 25, 2023 12:30
2D / 3D Cubic (bicubic / tricubic) interpolations implemented with torch
import torch
def spline_2d_torch(points, Z):
K = 4
N, _ = points.shape
H, W, C = Z.shape
coords = (torch.clamp(points, -1.0, 1.0) + 1.0) * 0.5 * (Z.shape[0] - 1)
vcoords = coords.type(dtype=torch.long, non_blocking=True)
rcoords = coords - vcoords