Skip to content

Instantly share code, notes, and snippets.

@twobob
twobob / whiten.html
Last active April 18, 2025 01:19
Service to remove sepia from open AI pictures. free. Client side
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DeSepAI Image</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.7.1/jszip.min.js"></script>
<style>
body { margin:0; padding:1rem; background:#121212; color:#e0e0e0; font-family:sans-serif; display:flex; justify-content:center; }
.container { background:#1e1e1e; padding:1.5rem; border-radius:6px; width:100%; max-width:800px; position:relative; }
@twobob
twobob / 3090.py
Created April 13, 2025 18:54
bd3lm on windows, perplexity
\conda\envs\bd3lm\python.exe -u main.py loader.eval_batch_size=16 model=small algo=bd3lm algo.backbone=hf_dit data=openwebtext-split data.insert_valid_special=False model.length=1024 model.attn_backend=sdpa block_size=4 eval.checkpoint_path=kuleshov-group/bd3lm-owt-block_size4 wandb=null mode=ppl_eval strategy=single_device
bd3lm on windows, perplexity
Validation DataLoader 0: 100%|█████████████████████████████████████████████████| 6891/6891 [1:54:19<00:00, 1.00it/s]
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
Validate metricDataLoader 0
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
sampling_eps_max1.0
sampling_eps_min0.0010000000474974513
@twobob
twobob / check_env_compatibility.py
Created April 13, 2025 13:39
Checking requirements from: requirements.txt against envs in conda with a percentage matching report.
import json
import subprocess
import sys
import os
from pathlib import Path
import configparser
import re
from packaging.requirements import Requirement, InvalidRequirement
from packaging.version import parse as parse_version, InvalidVersion
from packaging.specifiers import SpecifierSet, InvalidSpecifier
@twobob
twobob / import.cmd
Created March 6, 2025 18:11
"import cv2, mediapipe" tester for conda envs
conda env list --json | python -c "import json,sys,subprocess as sp; from pathlib import Path; envs=json.load(sys.stdin)['envs']; [print(e, 'HAS cv2+mediapipe' if sp.run([str(Path(e, 'python.exe')), '-c', 'import cv2, mediapipe'], stdout=sp.DEVNULL, stderr=sp.DEVNULL).returncode==0 else 'DOES NOT') for e in envs]"
@twobob
twobob / collage_lyra_bnb.py
Created February 11, 2025 04:37
a low calorie version of the very fine https://huggingface.co/bleepybloops/flux-collage-v1 for machines with 16GB and up (probably)
#!/usr/bin/env python
"""
This script demonstrates how to load a quantized Flux.1-dev model (4-bit, NF4)
using bitsandbytes with Diffusers and then apply a LoRA adapter.
It loads:
(a) the T5EncoderModel from the "text_encoder_2" subfolder in 4-bit mode, and
(b) the FluxTransformer2DModel from the "transformer" subfolder in 4-bit mode.
Then it instantiates a FluxPipeline with device_map="balanced" and applies LoRA.
"""
import re
from datasets import load_dataset, Dataset
# Load and prep dataset
SYSTEM_PROMPT = """
Respond in the following format:
<reasoning>
...
</reasoning>
<answer>
@twobob
twobob / shun.js
Last active January 30, 2025 11:54
shun bluesky poster and post in one click
javascript:(function(){function r(){return Math.floor(300*Math.random()+300)}function l(c){if("undefined"==typeof jQuery){var e=document.createElement("script");e.src="https://code.jquery.com/jquery-3.6.0.min.js";e.onload=function(){n("%E2%9C%85%20jQuery%20loaded");c&&c()};document.head.appendChild(e)}else{n("%E2%9C%85%20jQuery%20present");c&&c()}}function u(){if(!document.getElementById("s-status")){var e=document.createElement("div");e.id="s-status";e.style.cssText="position:fixed;bottom:10px;right:10px;padding:10px;background:#000;color:#fff;font-size:14px;border-radius:5px;opacity:.9;z-index:9999;max-width:300px";e.innerHTML='<strong>Shun%20Status:</strong><div%20id="s-log"></div>';document.body.appendChild(e)}}function n(e){u();var c=document.getElementById("s-log");c&&(c.innerHTML+=e+"<br>",clearTimeout(window.sTimeout),window.sTimeout=setTimeout(function(){c.innerHTML=""},1e4))}function t(){var e=$('[data-testid^="feedItem-by-"]');e.length?(e.each(function(){$(this).find(".s-btn").length||$(this).appen
@twobob
twobob / UniGifDepthMaterial.cs
Created January 28, 2025 04:53
mangle unigif to play Surface-Stable Fractal Dithering for purz POC
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using static System.Net.Mime.MediaTypeNames;
using System.Diagnostics;
/// <summary>
/// Loads and plays a GIF, assigning each frame to the material’s '_DepthTex' texture.
/// </summary>
@twobob
twobob / audio pipe.py
Created January 26, 2025 23:49
ideas for audio pipelines
#Phase 1: Data Preprocessing & Label Refinement
#1. Scraping Audio from YouTube
from yt_dlp import YoutubeDL
# Download audio from YouTube
def download_audio(url, output_dir="audio"):
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
using System.Collections.Generic;
using UnityEngine;
public static class StripUtility
{
// 1) Remove specified vertices
// 2) Re-sort remaining verts by angle around the centroid
// Ensures a consistent winding for a triangle strip after removal
public static void RemoveAndReorder(ref List<Vector3> verts, List<int> indicesToRemove)
{