Skip to content

Instantly share code, notes, and snippets.

View INF800's full-sized avatar
🍁
For truth we seek infinite and beyond.

Asapanna Rakesh INF800

🍁
For truth we seek infinite and beyond.
View GitHub Profile
@INF800
INF800 / crop_cell.py
Created February 2, 2021 09:20
detectron2 crop results
import numpy as np
import matplotlib.pyplot as plt
def get_bboxes_from(output):
""" returns list of bboxes """
return outputs["instances"].__dict__['_fields']['pred_boxes'].__dict__['tensor']
def crop(bbox, in_img: np.ndarray):
""" bbox is a list with xmin, ymin, xmax, ymax """
@INF800
INF800 / multipro_template.py
Created March 9, 2022 19:13 — forked from blaylockbk/multipro_template.py
Template for Python multiprocessing and multithreading
import multiprocessing #:)
def do_this(number):
print number
return number*2
# Create a list to iterate over.
# (Note: Multiprocessing only accepts one item at a time)
some_list = range(0,10)
@INF800
INF800 / fastapi_websocket_redis_pubsub.py
Created January 19, 2022 17:40 — forked from timhughes/fastapi_websocket_redis_pubsub.py
FastAPI Websocket Bidirectional Redis PubSub
"""
Usage:
Make sure that redis is running on localhost (or adjust the url)
Install uvicorn or some other asgi server https://asgi.readthedocs.io/en/latest/implementations.html
pip install -u uvicorn
Install dependencies
@INF800
INF800 / __init__.py
Last active November 15, 2021 23:44
FASTAPI Boilerplate
# empty
@INF800
INF800 / uninstall_python3.MD
Created October 9, 2021 22:31 — forked from zhensongren/uninstall_python3.MD
How to uninstall python3 from Ubuntu

To list all python versions in default locations

ls /usr/bin/python*

To remove just python3 package

sudo apt-get remove python3.5

plus it's dependent packages

sudo apt-get remove --auto-remove python3.5

plus configuration and/or data files of python3

sudo apt-get purge python3.5

1WBllCh7h5NjY09cvDby-amOO2FN0HbOA
@INF800
INF800 / cpu_bound_vs_io_bound.py
Last active September 12, 2021 23:33
multiprocessing vs multithreading for cpu-bound and io-bound tasks
# source: https://www.geeksforgeeks.org/difference-between-multithreading-vs-multiprocessing-in-python/
import time, os
from threading import Thread, current_thread
from multiprocessing import Process, current_process
COUNT = 200000000
SLEEP = 10
def io_bound(sec):
@INF800
INF800 / crime-det.ipynb
Created February 20, 2021 11:22
Crime-det.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@INF800
INF800 / test.py
Last active August 14, 2021 22:57
test
def f(*, a):
pass
f(1) # raises error
f(a=1) # works
@INF800
INF800 / commands.sh
Last active June 24, 2021 18:23
Docker commands
# ========================================================================================
# setup image
# ========================================================================================
# download or build image
docker build .
# ========================================================================================
# setup container
# ========================================================================================