Skip to content

Instantly share code, notes, and snippets.

@radames
radames / api-inference-Stable-Diffusion.py
Created February 1, 2023 20:16
Save Image from API inference Stable Diffusion on Hugging Face in Python
import json
import requests
from PIL import Image
import io
import re
from time import time
API_TOKEN = "" # token in case you want to use private API
headers = {
# "Authorization": f"Bearer {API_TOKEN}",
@radames
radames / grid.js
Created May 24, 2023 06:48
Amethyst Custom Layout Simple Square Grid
function layout() {
return {
name: "Grid",
getFrameAssignments: (windows, screenFrame) => {
const numWindows = windows.length;
const numRows = Math.floor(Math.sqrt(numWindows));
const numCols = Math.ceil(Math.sqrt(numWindows));
const cellWidth = screenFrame.width / numCols;
const cellHeight = screenFrame.height / numRows;