This file contains 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 functools | |
def force_async(fn): | |
''' | |
turns a sync function to async function using threads | |
''' | |
from concurrent.futures import ThreadPoolExecutor | |
import asyncio | |
pool = ThreadPoolExecutor() |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
// Place your key bindings in this file to overwrite the defaults | |
[{ | |
"key": "ctrl+a", | |
"command": "editor.action.selectAll" | |
}, | |
{ | |
"key": "ctrl+x", | |
"command": "editor.action.clipboardCutAction" | |
}, | |
{ |
This file contains 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 os | |
import random | |
import cv2 | |
import pandas as pd | |
import torch | |
from torch.utils.data import Dataset | |
from transformers import (BertTokenizerFast, PreTrainedTokenizerFast, | |
RobertaTokenizerFast) |
This file contains 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 segmentation_models_pytorch.encoders import get_encoder | |
from .mil import MILPool | |
def make_net_li2018( | |
backbone, | |
n_out, | |
n_in=1, | |
n_dec_ch=512, | |
out_size=20, |
This file contains 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 errno | |
import os | |
import time | |
from collections import defaultdict | |
from contextlib import ContextDecorator, contextmanager | |
from itertools import count | |
import torch | |
CUDA_ALLOC_FILE = os.path.expanduser('~/mlkit.alloc') |
This file contains 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
using System; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ProducerConsumer | |
{ |
This file contains 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
""" | |
blocks until a specific time, | |
useful for planning to run a script at a specific time | |
usage: | |
python til.py 13:00 tomorrow && python script.py | |
""" | |
import dateparser | |
from datetime import datetime, timedelta |
This file contains 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 select import select | |
import os | |
import time | |
import subprocess | |
from contextlib import contextmanager | |
@contextmanager | |
def pipe(): | |
r, w = os.pipe() |
This file contains 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 multiprocessing import Process | |
class CatchableProcess(Process): | |
def __init__(self, target, args=[], kwargs=dict()): | |
from multiprocessing import Queue | |
self.error = Queue(1) | |
self.result = Queue(1) | |
def wrapper(target, args, kwargs): | |
try: |
NewerOlder