Giter Club home page Giter Club logo

dino-ip-adapter-refiners's Introduction

dino-ip-adapter-refiners

Repository for training an IP adapter for DINO

Installation

You can install the package using pip:

pip install git+https://github.com/isamu-isozaki/dino-ip-adapter-refiners.git

or you can use the rye package manager:

rye sync

Training

Download Photo Concept Dataset

Download the dataset from the following link:

Photo Concept Dataset

To download the images from urls, you can use the (img2dataset)[https://github.com/rom1504/img2dataset] library for efficient downloading.

 img2dataset --url_list photo-concept-bucket/ --input_format "parquet" \
    --url_col "url" --caption_col "cogvlm_caption" --output_format webdataset \
    --output_folder photo-concept-bucket-webdataset --processes_count 16 --thread_count 64 --image_size 1024 \
    --resize_only_if_bigger False --resize_mode="center_crop"  --skip_reencode True

Pre-encoded Features

Create a .env file in the root of the project with the following variables:

PHOTO_CONCEPT=/path/to/photo-concept-bucket-webdataset
PHOTO_CONCEPT_PREENCODED=/save/path/

Because we're using webdatasets, you can save and load data from a remote location. We used Google Cloud Storage for this purpose.

Run the following command to precompute the features for the dataset:

python precompute_data.py --dataset photo_concept --start_shard 0 --end_shard 56 --batch_size 32

Batch size can be adjusted to fit the memory of the machine, 32 works for 40GB of memory.

If adding text encoder embeddings and working with mosaic you can encode with

 python precompute_data.py --dataset="photo_concept" --start_shard=0 --end_shard=56 --batch_size=32 --encode_prompt --use_mosaic --compression=zstd

If using mosaic encoding, .mds is added to PHOTO_CONCEPT_PREENCODED

Train Model

to .env add

TRAINING_PATH="/save/path"

but add .mds at the end if using mosaic.

To train the model, you can use the following command:

.venv/bin/python src/dino_ip_adapter_refiners

If using Mosaic, you first need to download index.json from PHOTO_CONCEPT_PREENCODED to the cache file location you specified. It will be along the lines of

gsutil cp GCP_SAVE_PATH/index.json CACHE_FOLDER_LOCATION

dino-ip-adapter-refiners's People

Contributors

isamu-isozaki avatar limiteinductive avatar

Stargazers

 avatar Cédric Deltheil avatar Laureηt avatar  avatar  avatar

Watchers

Kostas Georgiou avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.