MCPcopy Index your code
hub / github.com/damian0815/finetune-clip-huggingface

github.com/damian0815/finetune-clip-huggingface @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
12 symbols 48 edges 1 files 4 documented · 33% updated 3y ago★ 52
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Finetuning CLIP with huggingface libs

This notebook demonstrates how to finetune the type of CLIP models used for Stable Diffusion with huggingface libs on a self-defined dataset.

Based on the huggingface transformers CLIP example.

Dataset

The dataset should be provided as a collection of images as .jpg or .jpeg files. For each file, there should be a .txt file with the same name that contains the caption:

  • fluffy-dog.jpg
  • fluffy-dog.txt - caption for fluffy-dog.jpg, for example a picture of a fluffy dog.

In the huggingface_finetune_clip_runner.ipynb is a code cell that outputs a .json file in a format that huggingface datasets can understand for such a collection of files.

Finetuning

Load huggingface_finetune_clip_runner.ipynb in an environment that already has PyTorch and torchvision installed. Work through the cells one by one - you will need to change the root_folder and out_json to match your needs:

root_folder = "/Users/damian/2.current/stablediffusion/buzzybee/fullsize"
out_json = "/Users/damian/2.current/stablediffusion/buzzybee.json"

Core symbols most depended-on inside this repo

_freeze_params
called by 2
huggingface_finetune_clip.py
main
called by 1
huggingface_finetune_clip.py
forward
called by 0
huggingface_finetune_clip.py
collate_fn
called by 0
huggingface_finetune_clip.py
tokenize_captions
called by 0
huggingface_finetune_clip.py
transform_images
called by 0
huggingface_finetune_clip.py
filter_corrupt_images
called by 0
huggingface_finetune_clip.py

Shape

Function 6
Class 3
Method 3

Languages

Python100%

Modules by API surface

huggingface_finetune_clip.py12 symbols

For agents

$ claude mcp add finetune-clip-huggingface \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page