Skip to content

Instantly share code, notes, and snippets.

View johnmeade's full-sized avatar

John Meade johnmeade

  • Resemble AI
View GitHub Profile
@cannikin
cannikin / README.md
Last active January 21, 2026 18:30 — forked from p123ad/README.md
Use Raspberry Pi Camera with Prusa Connect

Use Raspberry Pi and Pi Cam for Prusa Connect

I couldn't get the script from p123ad to work on my Pi Zero W 2 with Camera Module 3 (all kinds of ffmpeg errors). There are several built-in tools for working with the camera now, so I tried to figure out if I could use one of those instead.

Behold this version, which uses the built-in libcamera-still tool to actually interact with the camera and save a JPEG. That image is then uploaded to Prusa Connect, same as the original script.

Instructions

  1. Go to the Cameras section at https://connect.prusa3d.com
  2. Add a new camera by clicking "Add new other camera"
@bsantraigi
bsantraigi / top-k-top-p-batched.py
Last active June 2, 2025 16:12
Batched top-k and top-p/nucleus sampling in PyTorch!
def top_k_top_p_filtering(logits, top_k=0, top_p=0.0, filter_value=-float('Inf')):
""" Filter a distribution of logits using top-k and/or nucleus (top-p) filtering
Args:
logits: logits distribution shape (vocabulary size)
top_k >0: keep only top k tokens with highest probability (top-k filtering).
top_p >0.0: keep the top tokens with cumulative probability >= top_p (nucleus filtering).
Nucleus filtering is described in Holtzman et al. (http://arxiv.org/abs/1904.09751)
Basic outline taken from https://gist.github.com/thomwolf/1a5a29f6962089e871b94cbd09daf317
"""