Skip to content

Instantly share code, notes, and snippets.

import sys
import time
import requests
import itertools
import numpy as np
import pandas as pd
from tqdm import tqdm
from PIL import Image
import sys
import time
import requests
import itertools
import numpy as np
import pandas as pd
from tqdm import tqdm
from PIL import Image
@qubvel
qubvel / compare_outputs.py
Created June 6, 2024 16:15
Compare image processors across branches
import os
import glob
import torch
from typing import Mapping
# get current file directory
file_dir = os.path.dirname(os.path.realpath(__file__))
branch_1 = "main"
branch_2 = "clean-up-do-reduce-labels"
import torch
from collections import OrderedDict
from typing import List
checkpoints_weights_paths: List[str] = ... # sorted in descending order by score
model: torch.nn.Module = ...
def average_weights(state_dicts: List[dict]):
everage_dict = OrderedDict()
@qubvel
qubvel / dataset.py
Last active September 25, 2019 23:06
class TestDataset(Dataset):
def __init__(self, base_path, ids, transform):
self.base_path = base_path
self.ids = ids
self.transform = transform
def __getitem__(self, i):
sample = self.get_sample(i)
if self.transform is not None:
@qubvel
qubvel / tf2keras.py
Last active June 14, 2019 21:39
Code example for converting TF weights to Keras
import pickle
from keras.layers import Conv2D, BatchNormalization, Dense
# NOTE!
# It is supposed to be used with python 3.6+ as it is rely on ordered keys of dict
def get_name(name):
"""Parse name"""
parts = name.split('/')[:-1]
return '/'.join(parts)