Skip to content

Instantly share code, notes, and snippets.

# on local machine
git clone https://github.com/comfyanonymous/ComfyUI
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
cd ../
# start docker
docker run --name comfyui -p 8188:8188 -it --rm --gpus all -v $PWD:/workspace pytorch/pytorch:2.2.1-cuda12.1-cudnn8-devel bash
apt-get update
apt-get install wget git libgl1 libglib2.0-0 -y
@josephrocca
josephrocca / removeExifFromJpeg.js
Created August 18, 2023 11:50
Remove EXIF data from JPEG using JavaScript - simple and extremely fast
// Code mostly written by GPT-4. Works well for me, but not extensively tested (e.g. on old or weird jpeg files)
function removeExifFromJpeg(arrayBuffer) {
let view = new DataView(arrayBuffer);
// Check if it's a JPEG file
if (view.getUint16(0, false) !== 0xFFD8) {
throw new Error("Not a valid JPEG");
}
let position = 2; // Start after the SOI marker
@josephrocca
josephrocca / e5-large-v2.js
Last active October 25, 2023 01:29
e5-large-v2 text embedding model in JavaScript using Transformers.js
// See the comments at the end for a model that does much better than e5-large-v2 while being a third of the size.
let { pipeline } = await import('https://cdn.jsdelivr.net/npm/@xenova/transformers@2.7.0');
let extractor = await pipeline('feature-extraction', 'Xenova/e5-large-v2');
// Note: If you're just comparing "passages" with one another, then just prepend "passage: " to all texts. Only use "query: " if the text is a short "search query" like in the above example.
let passage1 = await extractor(`passage: The Shawshank Redemption is a true masterpiece of cinema.`, { pooling: 'mean', normalize: true });
let passage2 = await extractor(`passage: The film should not be exposed to sunlight when removing it from the wrapper. Otherwise your movie will come out bad.`, { pooling: 'mean', normalize: true });
let query = await extractor(`query: movie review`, { pooling: 'mean', normalize: true });
// This is a version of this file: https://w3c.github.io/webcodecs/samples/capture-to-file/webm-writer2.js
// With these fixed applied: https://github.com/w3c/webcodecs/issues/332#issuecomment-1077442192
/**
* A tool for presenting an ArrayBuffer as a stream for writing some simple data
* types.
*
* By Nicholas Sherlock, with updates from jimbankoski
*
* - make it work off frames with timestamps from webcodecs
@josephrocca
josephrocca / createCanvasFromRGBAData.js
Created December 1, 2022 10:52
RGBA data to canvas - create a canvas from RGB data
function createCanvasFromRGBAData(data, width, height) {
// `data` should look something like [[123,32,40,255], [3,233,42,120], ...]
if(width*height !== data.length) throw new Error("width*height should equal data.length");
let canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
let ctx = canvas.getContext("2d");
let imgData = ctx.createImageData(width, height);
for(let i = 0; i < data.length; i++) {
imgData.data[i*4+0] = data[i][0];
@josephrocca
josephrocca / notebook.ipynb
Last active November 14, 2022 00:49
lyra-v2-soundstream split quantizer into its two subgraphs.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@josephrocca
josephrocca / onnx-runtime-python-inference.ipynb
Last active October 30, 2022 16:53
onnx-runtime-python-inference.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@josephrocca
josephrocca / aaa_usage.js
Created October 29, 2022 07:33
AWS S3 (v3) working in Deno
import * as AWS from "./aws_sdk_client_s3_v3.198.0-es.js";
let s3 = new AWS.S3({
region: "YOUR_REGION",
endpoint: "YOUR_ENDPOINT_URL_IF_NECCESSARY",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET",
},
});
@josephrocca
josephrocca / notebook.ipynb
Last active November 28, 2022 10:37
jax2tf2onnx - jax.lax.switch with functions.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@josephrocca
josephrocca / stable_diffusion_jax-to-onnx.ipynb
Last active October 20, 2022 14:42
stable_diffusion_jax-to-onnx - scheduler_loop_body.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.