Skip to content

Instantly share code, notes, and snippets.

View eugene123tw's full-sized avatar

Eugene Liu eugene123tw

View GitHub Profile
@eugene123tw
eugene123tw / pytorch_bilinear_interpolation.md
Created June 13, 2023 21:49 — forked from peteflorence/pytorch_bilinear_interpolation.md
Bilinear interpolation in PyTorch, and benchmarking vs. numpy

Here's a simple implementation of bilinear interpolation on tensors using PyTorch.

I wrote this up since I ended up learning a lot about options for interpolation in both the numpy and PyTorch ecosystems. More generally than just interpolation, too, it's also a nice case study in how PyTorch magically can put very numpy-like code on the GPU (and by the way, do autodiff for you too).

For interpolation in PyTorch, this open issue calls for more interpolation features. There is now a nn.functional.grid_sample() feature but at least at first this didn't look like what I needed (but we'll come back to this later).

In particular I wanted to take an image, W x H x C, and sample it many times at different random locations. Note also that this is different than upsampling which exhaustively samples and also doesn't give us fle

@eugene123tw
eugene123tw / launch.json
Created May 16, 2022 13:39 — forked from beaukinstler/launch.json
vscode launch.json for python flask and pytest
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
@eugene123tw
eugene123tw / t-ortcpu.cc
Created September 9, 2021 20:06 — forked from pranavsharma/t-ortcpu.cc
onnxruntime C++ API inferencing example for CPU
// Copyright(c) Microsoft Corporation.All rights reserved.
// Licensed under the MIT License.
//
/*
pranav@XXX:~$ wget https://github.com/microsoft/onnxruntime/releases/download/v1.8.1/onnxruntime-linux-x64-1.8.1.tgz
....
2021-07-28 19:44:06 (7.60 MB/s) - ‘onnxruntime-linux-x64-1.8.1.tgz’ saved [4736207/4736207]
pranav@XXX:~$ tar xvfz onnxruntime-linux-x64-1.8.1.tgz
@eugene123tw
eugene123tw / c_cpp_properties.json
Last active April 16, 2020 13:52
PyTorch VSCode c-cpp properties
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/python3.6m",
"/usr/local/cuda-10.0/targets/x86_64-linux/include",
"{PYTORCH_ENV}/lib/python3.6/site-packages/torch/include",
"{PYTORCH_ENV}/lib/python3.6/site-packages/torch/include/torch/csrc/api/include",
@eugene123tw
eugene123tw / postgres-brew.md
Last active April 5, 2020 11:18 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@eugene123tw
eugene123tw / Django EC2 Bad Request (400)
Created March 13, 2020 15:04 — forked from eezis/Django EC2 Bad Request (400)
Resolving Bad Request (400) when using Django on an EC2 instance DEBUG
This gist pertains to a Bad Request(400) error when trying to access an EC2 instance running django . . .
I set up an EC2 server, installed django, started runserver and tested. The result was
Bad Request (400)
When using Django 1.5 and higher, when DEBUG=False in the settings.py file, you must specify ALLOWED_HOSTS
or you will recieve a "Bad Request (400)" error message when attempting to retrieve a page.
On an Amazone EC2 instance, if you are testing with the public DNS, then you should put the public DNS in
@eugene123tw
eugene123tw / gitflow-breakdown.md
Created July 22, 2019 08:42 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@eugene123tw
eugene123tw / .bashrc
Created March 19, 2019 10:06
git prompt
export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0;32m\]$(__git_ps1)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
@eugene123tw
eugene123tw / multiple_gcc.MD
Created September 2, 2018 20:51
How to use multiple instances of gcc?

How to use multiple instances of gcc?

You need to let update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use.

This is done with the following:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
sudo update-alternatives --config gcc
import pickle
import numpy as np
from data_processor import *
import tensorflow as tf
from tool import *
from model import LeNet
def detect():
### Replace each question mark with the appropriate value.
### Use python, pandas or numpy methods rather than hard coding the results