Skip to content

Instantly share code, notes, and snippets.

View smellslikeml's full-sized avatar
👃
You smell that?

smellslikeml smellslikeml

👃
You smell that?
View GitHub Profile
@smellslikeml
smellslikeml / llm_request_aggregator.py
Created March 11, 2024 18:00
Uses NATS to aggregate responses from workers publishing LLM inference to the subject inference.requests
import asyncio
import nats
import uuid
async def aggregate_inferences(nats_url, request_subject, data, timeout=10):
nc = await nats.connect(nats_url)
responses = []
@smellslikeml
smellslikeml / llm_worker.py
Last active March 11, 2024 18:27
Uses NATS to publish responses of LLM inference to the subject inference.requests
# Launch nats-server
# wget https://huggingface.co/remyxai/stablelm-zephyr-3B_localmentor/resolve/main/ggml-model-q4_0.gguf -o stablelm-localmentor_2.gguf
import nats
import asyncio
from llama_cpp import Llama
async def llm_runner(nats_url, model_path, subject):
nc = await nats.connect(nats_url)
llm = Llama(model_path)
@smellslikeml
smellslikeml / train_dreambooth_lora_sdxl.py
Created December 20, 2023 23:17
Modified data loader - train_dreambooth_lora_sdxl.py
#!/usr/bin/env python
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@smellslikeml
smellslikeml / concat_script.sh
Created June 26, 2023 04:03
Concatenate videos with ffmpeg
#!/bin/bash
# Ensure a list of clips is provided
if [ $# -eq 0 ]; then
echo "Please provide a list of clips to process and concatenate."
exit 1
fi
# Directory to store processed clips
mkdir -p processed_clips
@smellslikeml
smellslikeml / video_llama_eval.yaml
Created June 25, 2023 22:38
Video-LLaMA eval config for Colab
model:
arch: video_llama
model_type: pretrain_vicuna
freeze_vit: True
freeze_qformer: True
max_txt_len: 160
end_sym: "###"
low_resource: True
frozen_llama_proj: False
@smellslikeml
smellslikeml / client_example.py
Last active April 19, 2023 03:09
U^2Net Triton Inference Server
import os
import time
import cv2
import hashlib
import numpy as np
from PIL import Image
from absl import logging
import tritonclient.http
@smellslikeml
smellslikeml / marker_viz.py
Created April 23, 2022 14:29
example of visualizing markers
#!/usr/bin/env python3
import sys
import rospy
import rostopic
import numpy as np
import message_filters
import cv2
import numpy as np
from collections import deque
# https://github.com/elliottzheng/face-detection
from face_detection import RetinaFace
# https://pyscenedetect.readthedocs.io/projects/Manual/en/latest/api/scene_manager.html#scenemanager-example
from scenedetect import VideoManager
from scenedetect import SceneManager
# http://index-of.es/Varios-2/Practical%20Python%20AI%20Projects%20Mathemathical%20Models%20of%20Optimization%20Problems%20with%20Google%20OR-Tools.pdf
# coding: utf-8
"""
Example code for solving the transshipment problem. (pg. 111)
Input is an NxN numpy matrix (referenced here as D)
where row N is the demand and column N is the supply for each location 0 through N-1.
To solve, call the solve_model() function with matrix D as the input.
"""
@smellslikeml
smellslikeml / visual_anomaly_detection_demo.py
Created December 15, 2019 19:28
A simple script to perform webcam visual anomaly detection with autoencoders built with Keras
#!/usr/bin/python3
from __future__ import absolute_import, print_function
import cv2
import numpy as np
from time import sleep, time
from collections import deque
from tensorflow.keras.models import Model
from tensorflow.keras.optimizers import RMSprop
from tensorflow.keras.layers import Input, Conv2D, MaxPooling2D, UpSampling2D, ZeroPadding2D