Skip to content

Instantly share code, notes, and snippets.

from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, LCMScheduler, AutoencoderTiny
import numpy as np
import torch
import cv2
from PIL import Image
# load control net and stable diffusion v1-5
controlnet = ControlNetModel.from_pretrained("lllyasviel/sd-controlnet-canny", torch_dtype=torch.float16)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"lykon/dreamshaper-8-lcm", controlnet=controlnet, torch_dtype=torch.float16, safety_checker = None
#!/bin/bash
# Step 0: Ensure .cache and .local link are symlinks
if [ ! -L ~/.cache ]; then
# create the directory if it doesn't exist
mkdir -p /vast/${USER}/.cache
ln -s /vast/${USER}/.cache ~/.cache
fi
if [ ! -L ~/.local ]; then
# Define the installation path
INSTALL_PATH="/vast/${USER}/comfyui/"
# create directory if it doesn't exist
mkdir -p "${INSTALL_PATH}"
# create comfyui_models.txt if it doesn't exist
if [ ! -f "${INSTALL_PATH}/comfyui_models.txt" ]; then
# get the default modles file from gist: https://gist.githubusercontent.com/venetanji/7be194b3f943ff0597fa11f37d14fc1b/raw/881b73837a643db008fc13f503464a746b931eb5/comfyui_models.txt
curl -s https://gist.githubusercontent.com/venetanji/7be194b3f943ff0597fa11f37d14fc1b/raw/881b73837a643db008fc13f503464a746b931eb5/comfyui_models.txt > "${INSTALL_PATH}/comfyui_models.txt"
# Stable Cascade
#https://huggingface.co/stabilityai/stable-cascade/resolve/main/comfyui_checkpoints/stable_cascade_stage_c.safetensors
# dir=models/checkpoints
# out=stable_cascade_stage_c.safetensors
#https://huggingface.co/stabilityai/stable-cascade/resolve/main/comfyui_checkpoints/stable_cascade_stage_b.safetensors
# dir=models/checkpoints
# out=stable_cascade_stage_b.safetensors
#https://huggingface.co/stabilityai/stable-cascade/resolve/main/controlnet/canny.safetensors
# dir=models/controlnet
@venetanji
venetanji / ndi-asyncio
Last active December 12, 2023 16:54
ndi asyncio opencv
import sys
import numpy as np
import cv2 as cv
import NDIlib as ndi
import re
import asyncio
from pythonosc import udp_client
from facenet_pytorch import MTCNN
from hsemotion.facial_emotions import HSEmotionRecognizer
import torch
import cv2
import asyncio
import time
# open camera and get video capture object
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
# set camera resolution
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
size=10
cap.set(cv2.CAP_PROP_BUFFERSIZE,size)
/*
Esp8266 Websockets Client
This sketch:
1. Connects to a WiFi network
2. Connects to a Websockets server
3. Sends the websockets server a message ("Hello Server")
4. Prints all incoming messages while the connection is open
Hardware:
const tf = require('@tensorflow/tfjs-node-gpu');
const cv = require("@u4/opencv4nodejs");
const posenet = require("@tensorflow-models/posenet")
let camera = new cv.VideoCapture(0);
camera.set(cv.CAP_PROP_FRAME_WIDTH, 640);
camera.set(cv.CAP_PROP_FRAME_HEIGHT, 480);
async function loadPosenet() {
net = await posenet.load({
#include <Arduino.h>
#ifdef ESP32
#include <WiFi.h>
#include "SPIFFS.h"
#else
#include <ESP8266WiFi.h>
#endif
#include "AudioFileSourceSPIFFS.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
#include <ESP8266WiFi.h>
#include <ArduinoWebsockets.h>
// include wpa2 enterprise code
extern "C" {
#include "user_interface.h"
#include "wpa2_enterprise.h"
}
// SSID, Username and password. Update with yours!