Skip to content

Instantly share code, notes, and snippets.

View achalddave's full-sized avatar

Achal Dave achalddave

View GitHub Profile
@achalddave
achalddave / install_caffe.sh
Last active August 2, 2022 12:33
This is a script to compile caffe without root permission. It hasn't been extensively tested, but it will hopefully still make things easier than going about it on your own. Please let me know if there are any bugs!
# This script installs (or at least, attempts to install) Caffe in CPU mode
# with Python bindings without root permission. In doing so, it installs the
# following dependencies:
#
# * protobuf
# * cmake
# * gflags
# * glog
# * opencv
# * hdf5
@achalddave
achalddave / patch_clip_model.sh
Last active April 27, 2022 06:37
Patch CLIP models to work with torch versions before 1.7
#!/bin/bash
###
# Patch CLIP models to work with PyTorch versions before 1.7.
# This script was tested with PyTorch 1.6 and CUDA 9.2 on the RN-50 and ViT-B-32 models.
###
if [[ "$#" != 1 ]] ; then
echo "Usage: $0 <clip-model-pt>"
echo "Example: $0 $HOME/.cache/clip/RN50.pt"
exit 1
{"id": "lvis", "name": "LVIS", "children": [{"id": 1, "name": "entity.n.01", "children": [{"id": 194, "name": "physical_entity.n.01", "children": [{"id": 459, "name": "object.n.01", "children": [{"id": 2018, "name": "part.n.02", "children": [{"id": 1584, "name": "piece_of_cloth.n.01", "children": [{"id": 1590, "name": "sail.n.01", "children": []}, {"id": 1585, "name": "towel.n.01", "children": [{"id": 508, "name": "bath_towel.n.01", "children": []}, {"id": 1588, "name": "paper_towel.n.01", "children": []}, {"id": 1587, "name": "hand_towel.n.01", "children": []}, {"id": 1586, "name": "dishtowel.n.01", "children": []}]}, {"id": 1592, "name": "bandanna.n.01", "children": []}, {"id": 1589, "name": "dishrag.n.01", "children": []}]}, {"id": 2028, "name": "doorknob.n.01", "children": []}, {"id": 2024, "name": "wall_socket.n.01", "children": []}]}, {"id": 460, "name": "whole.n.02", "children": [{"id": 1986, "name": "natural_object.n.01", "children": [{"id": 2017, "name": "nest.n.01", "children": []}, {"id": 1991, "na
#!/bin/bash
# Save current git diff, log, status to output directory.
#
# Example usage:
# ./dump_git_info.sh /path/to/output/directory/
# ./dump_git_info.sh /path/to/output/directory/ /path/to/git/repo/
#
# Writes the following files to output_dir:
#
# git-status.txt: Output of git status -sb.
@achalddave
achalddave / main.py
Last active February 13, 2018 01:55
Argparse load config from file
"""Use argparse to load arguments from file before command line.
MIT License
Copyright (c) 2018 Achal Dave
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@achalddave
achalddave / flop_computation_network.ipynb
Created October 11, 2017 18:35
Compute number of flops in a CNN
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@achalddave
achalddave / Snap-SVG-Current.js
Created December 5, 2012 04:28
Current Snap SVG Rasterizing
function readImage(aFile) {
var pic = new Image(),
frd = new FileReader();
while (!target.droppedImage) {
target = target.parent;
}
pic.onload = function () {
canvas = newCanvas(new Point(pic.width, pic.height));
canvas.getContext('2d').drawImage(pic, 0, 0);
target.droppedImage(canvas, aFile.name);
"""Dump features calculated from a network using Caffe.
Run 'python frame_features.py --help' for usage information.
"""
import argparse
import csv
import errno
import logging
import numpy as np
@achalddave
achalddave / maptable_clearstate_bug.lua
Created February 20, 2017 17:20
Displays memory 'leak' with nn.MapTable after call to clearState()
--[[ Displays memory 'leak' with nn.MapTable after clearState() ]]--
local nn = require 'nn'
local cunn = require 'cunn'
model = nn.MapTable():add(nn.SpatialConvolution(3, 256, 3, 3, 1, 1, 1, 1, 1))
:cuda()
i = {torch.rand(30, 3, 224, 224):cuda(), torch.rand(30, 3, 224, 224):cuda()}
function check_mem() os.execute('nvidia-smi | grep luajit') end
@achalddave
achalddave / lyaml-null.md
Last active October 7, 2016 16:34
lyaml library parses null in yaml as a string. See https://github.com/gvvaughan/lyaml/issues/13 for discussion
th> lyaml = require 'lyaml'
                                                                      [0.0016s]
th> out = lyaml.load('key: null')
                                                                      [0.0002s]
th> out.key
null
                                                                      [0.0000s]
th> type(out.key)
string