This is a gist on how to get StreamDiffusion running on a Mac (mps)
git clone https://github.com/cumulo-autumn/StreamDiffusion.gitcd StreamDiffusion| #!/usr/bin/env bash | |
| set -euo pipefail | |
| # patch-claude-code.sh — Rebalance Claude Code prompts to fix corner-cutting behavior | |
| # | |
| # What this does: | |
| # Patches the npm-installed @anthropic-ai/claude-code cli.js to rebalance | |
| # system prompt instructions that cause the model to cut corners, simplify | |
| # excessively, and defer complicated work. | |
| # |
| void depth_pyramid(MTL::CommandBuffer *commandBuffer) { | |
| uint32_t zero = 0; | |
| memcpy(_spdAtomicBuffer->contents(), &zero, sizeof(uint32_t)); | |
| MTL::ComputeCommandEncoder* encoder = commandBuffer->computeCommandEncoder(); | |
| encoder->setLabel(NS::String::string("Depth Pyramid SPD", NS::ASCIIStringEncoding)); | |
| encoder->setComputePipelineState(_depthPyramidPSO); | |
| encoder->setTexture(depthTexture, 0); | |
| encoder->setTexture(_depthPyramidTexture, 1); |
| # This gist shows how to speed up graphene_django by short-cutting the field and type resolution of the returned JSON and | |
| # using a bit of caching to avoid having to repeat our discovery/decision process across multiple fields of the same | |
| # type. It relies on trusting the developer to always return the correct types and respect non-nullability. | |
| # Assumes that: | |
| # 1. You're not using async code | |
| # 2. You're using graphql_sync_dataloader to solve the N+1 problem | |
| # 3. You're not using any graphene middleware other than for authentication | |
| # 4. Your resolvers will all respect the schema | |
| # 5. See code comments for further limitations |
git clone https://github.com/cumulo-autumn/StreamDiffusion.gitcd StreamDiffusionSee the new site: https://postgresisenough.dev
| import torch | |
| import torch.nn.functional as F | |
| import coremltools as ct | |
| from torch import Tensor | |
| from torch import nn | |
| from typing import Dict | |
| from typing import Optional | |
| from ane_transformers.reference.layer_norm import LayerNormANE as LayerNormANEBase | |
| from coremltools.models.neural_network.quantization_utils import quantize_weights |
| import AVKit | |
| import Foundation | |
| class VideoHelper { | |
| static func getThumbnail(from player: AVPlayer, at time: CMTime, maximumSize: CGSize? = nil) -> CGImage? { | |
| guard let currentItem = player.currentItem else { return nil } | |
| return getThumbnail(from: currentItem.asset, at: time, maximumSize: maximumSize) | |
| } |
A Step-By-Step Guide from Unboxing to Creative Coding
| # based on https://github.com/kylerbrown/ezdtw | |
| # with modifications to be fully njit-able | |
| import numpy as np | |
| from numba import njit | |
| @njit | |
| def sqeuclidean(a, b): | |
| return np.sum((a - b)**2) |