Skip to content

Instantly share code, notes, and snippets.

@apolinario
apolinario / README.md
Created July 2, 2026 12:36
Krea 2 Image Reference — training-free style transfer via Untwisting RoPE (diffusers). Demo: https://huggingface.co/spaces/multimodalart/Krea-2-Image-Reference
@apolinario
apolinario / gist-setup.sh
Last active July 13, 2026 14:59
Set up hf CLI + skills for building Hugging Face Spaces with a coding agent (pre-merge test build for huggingface/skills#153)
#!/usr/bin/env bash
# Get your shell ready to build Hugging Face Spaces with a coding agent.
#
# Usage:
# curl -LsSf https://<your-gist-url>/gist-setup.sh | bash
#
# Or download, read, then `bash gist-setup.sh`.
#
# Idempotent: re-running is safe — each step skips itself if already done.
#
@apolinario
apolinario / gist:feae34f89fd00278e9ce8f9215190e95
Last active May 28, 2026 07:46
Hugging Face Spaces - teach your agent how to create a machine learning app or demo with Spaces
---
name: huggingface-spaces
description: Build, deploy, and maintain applications on Hugging Face Spaces — Gradio / Docker / Static SDKs, ZeroGPU and dedicated hardware, model loading, debugging, buckets, inference providers, community grants. Use whenever the user asks to create or host an app on Hugging Face, port code onto ZeroGPU, fix a Space that won't build or run, or otherwise work with `hf spaces …`, `@spaces.GPU`, Space README frontmatter, or the `spaces` Python package.
---
# Hugging Face Spaces
Hugging Face Spaces host machine-learning applications. There are 1M+ today; each Space is a git repo. This skill covers creating, building, debugging, and maintaining them.
## 0. Getting ready
@apolinario
apolinario / flux_style_shaping.py
Last active December 19, 2024 22:03
Move models outside of the generation function
import os
import random
import sys
from typing import Sequence, Mapping, Any, Union
import torch
import gradio as gr
from huggingface_hub import hf_hub_download
import spaces
from comfy import model_management
@apolinario
apolinario / convert_diffusers_sdxl_lora_to_webui.py
Created December 30, 2023 02:23
Script for converting a HF Diffusers trained SDXL LoRAs (be it in the old, new or PEFT format) to the Kohya format used by some WebUIs such as AUTOMATIC1111, ComfyUI, SD.Next and others.
# Script for converting a HF Diffusers trained SDXL LoRAs (be it in the old, new or PEFT format)
# To the Kohya format used by some WebUIs such as AUTOMATIC1111, ComfyUI, SD.Next and others.
import argparse
import os
import torch
from safetensors.torch import load_file, save_file
from diffusers.utils import convert_state_dict_to_peft, convert_unet_state_dict_to_peft