Skip to content

Instantly share code, notes, and snippets.

@deltheil
deltheil / self_attention_guidance.sh
Created October 12, 2023 08:24
Self-Attention Guidance with Refiners: prerequisites
# Improving Sample Quality of Diffusion Models Using Self-Attention Guidance
# https://arxiv.org/abs/2210.00939
# https://github.com/SusungHong/Self-Attention-Guidance
# (1) Install (see also https://github.com/finegrain-ai/refiners#install)
git clone https://github.com/finegrain-ai/refiners.git
cd refiners
poetry install --all-extras
poetry run pip install --upgrade torch torchvision
@deltheil
deltheil / t2i_adapter_refiners.sh
Created October 2, 2023 12:00
T2I-Adapter with Refiners: prerequisites
# T2I-Adapter: Learning Adapters to Dig out More Controllable Ability for Text-to-Image Diffusion Models
# https://github.com/TencentARC/T2I-Adapter
# https://huggingface.co/blog/t2i-sdxl-adapters
# (1) Install (see also https://github.com/finegrain-ai/refiners#install)
git clone https://github.com/finegrain-ai/refiners.git
cd refiners
poetry install --all-extras
poetry run pip install --upgrade torch torchvision
@deltheil
deltheil / ip_adapter_refiners.sh
Last active October 2, 2023 08:29
IP-Adapter Plus with Refiners: prerequisites
# IP-Adapter: Text Compatible Image Prompt Adapter for Text-to-Image Diffusion Models
# https://github.com/tencent-ailab/IP-Adapter
# (1) Install (see also https://github.com/finegrain-ai/refiners#install)
git clone https://github.com/finegrain-ai/refiners.git
cd refiners
poetry install --all-extras
poetry run pip install --upgrade torch torchvision
# (2) Convert weights into Refiners format
@deltheil
deltheil / torch-test.sh
Created January 13, 2016 09:40
Run a single Torch7 test
# Example: to run `torchtest.topK` do
luajit -ltorch -e "torch.test('topK')"
@deltheil
deltheil / lsqlite3.sh
Created January 9, 2016 11:00
LuaRocks: path-related variables for external dependencies
# e.g. with lsqlite3
#
# see https://github.com/keplerproject/luarocks/blob/7a7c124/src/luarocks/deps.lua#L522-L529
luarocks SQLITE_INCDIR=/usr/local/opt/sqlite/include SQLITE_LIBDIR=/usr/local/opt/sqlite/lib install lsqlite3
@deltheil
deltheil / info.c
Created November 25, 2015 13:07
Check if libcurl was built with async DNS support
#include <stdio.h>
#include <curl/curl.h>
int
main(void)
{
curl_version_info_data *info = curl_version_info(CURLVERSION_NOW);
printf("async DNS: %d\n", !!(info->features & CURL_VERSION_ASYNCHDNS));
return 0;
}
@deltheil
deltheil / argcheck.lua
Created November 12, 2015 16:56
Playing with torch/argcheck
require 'torch'
local argcheck = require 'argcheck'
local env = require 'argcheck.env'
function env.istype(obj, typename)
if typename == 'torch.Tensor' then
-- could also check the storage type!
return torch.isTensor(obj)
else
require 'torch'
-- pre-req: luarocks install csv
local csv = require "csv"
local inputs, labels = {}, {}
local f, i = csv.open("data.csv"), 0
for fields in f:lines() do
if i > 0 then -- skip header
inputs[i] = {unpack(fields, 1, 18)}
@deltheil
deltheil / jq.sh
Last active August 29, 2015 14:11
Use jq command-line JSON processor to filter out a nested hash. See also: https://github.com/stedolan/jq/wiki/jq%20Cookbook
# http://stedolan.github.io/jq/
json='{"foo": {"genre":"deep house"}, "bar": {"genre": "progressive house"}, "baz": {"genre": "dubstep"}}'
echo "$json" | jq '[to_entries | .[] | select(.value.genre | contains("house"))] | from_entries'
# {
# "bar": {
# "genre": "progressive house"
# },
# "foo": {
# "genre": "deep house"