This file contains hidden or 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 base64 | |
import numpy as np | |
import cv2 | |
def svg(tensor, K = 10, font_size = 0.03): | |
min_score, max_score = tensor.min(), tensor.max() | |
labels = np.arange(min_score, max_score, float(max_score - min_score) / K) | |
bgr_image = cv2.applyColorMap((tensor - min_score) * 255. / (max_score - min_score), dtype = np.uint8), cv2.COLORMAP_JET) | |
bgr_jet = cv2.applyColorMap(np.arange(255, dtype = np.uint8), cv2.COLORMAP_JET).squeeze(1) |
This file contains hidden or 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
# print(next(iter(FFmpeg('video.mp4')))[0].shape) | |
# (480, 640, 3) | |
# print(next(iter(FFmpeg('video.mp4')))[1]) | |
# 0.0799333 | |
import subprocess | |
import json | |
import re | |
import numpy as np |
This file contains hidden or 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 sys | |
import urllib | |
import urlparse | |
sys.modules['urllib.request'] = type('', (object, ), dict(urlretrieve = staticmethod(urllib.urlretrieve))) | |
sys.modules['urllib.parse'] = type('', (object, ), dict(urlparse = staticmethod(urlparse.urlparse))) |
This file contains hidden or 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
# References: | |
# [1] Multimodal Compact Bilinear Pooling for Visual Question Answering and Visual Grounding, Fukui et al., https://arxiv.org/abs/1606.01847 | |
# [2] Compact Bilinear Pooling, Gao et al., https://arxiv.org/abs/1511.06062 | |
# [3] Fast and Scalable Polynomial Kernels via Explicit Feature Maps, Pham and Pagh, https://chbrown.github.io/kdd-2013-usb/kdd/p239.pdf | |
# [4] Fastfood — Approximating Kernel Expansions in Loglinear Time, Le et al., https://arxiv.org/abs/1408.3060 | |
# [5] Original implementation in Caffe: https://github.com/gy20073/compact_bilinear_pooling | |
# TODO: migrate to use of new native complex64 types | |
# TODO: change strided x coo matmul to torch.matmul(): M[sparse_coo] @ M[strided] -> M[strided] |
This file contains hidden or 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
# Usage: | |
# bash image2urijpeg.sh image.jpg 320x240 > base64.txt # will resize before conversion | |
# bash image2urijpeg.sh image.jpg > base64.txt # will keep original size | |
magick "$1" -resize ${2:--} jpeg:- | openssl enc -base64 -A | sed -e 's/^/data:image\/jpeg;base64,/' |
This file contains hidden or 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
ffmpeg -y -video_size 800x600 -offset_x 10 -offset_y 120 -framerate 5 -show_region 1 -f gdigrab -an -i desktop -vf scale=320:240 output.gif |
This file contains hidden or 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
echo $(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c10) | |
alias genpass='echo $(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c10)' |
This file contains hidden or 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
PREFIX=$PWD/env | |
export CUDA_HOME=/usr/local/cuda-9.0 | |
export CMAKE_PREFIX_PATH=$PREFIX | |
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH | |
export CPATH=$PREFIX/include:$CPATH | |
export PATH=$PREFIX/bin:$CUDA_HOME/bin:${PATH//"/home/cvlab/anaconda3/bin"/} | |
export CUDNN_LIB_DIR=$PREFIX/lib | |
export CUDNN_INCLUDE_DIR=$PREFIX/include |
This file contains hidden or 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
jupyter lab --NotebookApp.token='' | |
alias runjupyter="jupyter lab --NotebookApp.token='' --port 6006 --no-browser --ip=\"0.0.0.0\" --allow-root --NotebookApp.iopub_msg_rate_limit=1000000.0 --NotebookApp.iopub_data_rate_limit=100000000.0 --NotebookApp.notebook_dir=/" | |
alias mapports='ssh -L 7006:localhost:7006' |
This file contains hidden or 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
# prettifyjson input.json > output.json | |
alias prettifyjson='python3 -c "import json, sys; json.dump(json.load(open(sys.argv[1])), sys.stdout, ensure_ascii = False, indent = 2)"' |