GithubHelp home page GithubHelp logo

thu-syh / downstream-dinov2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from itsprakhar/downstream-dinov2

0.0 0.0 0.0 79.52 MB

Downstream-Dino-V2: A GitHub repository featuring an easy-to-use implementation of the DINOv2 model by Facebook for downstream tasks such as Classification, Semantic Segmentation and Monocular depth estimation.

License: Other

Python 7.71% Jupyter Notebook 92.29%

downstream-dinov2's Introduction

Downstream-Dino-V2

Welcome to the Downstream-Dinov2 repository! This project provides an easy-to-use implementation of the DINOv2 model developed by Facebook, allowing you to train it for downstream tasks effectively.

ToDo

✅ Add classification model
✅ Add training and inference code for classification model
✅ Add exapmle notebook
✅ Add segmentation model
✅ Add training code for segmentation model
✅ Add Segmentation model to the example notebook
☐ Refactot the code for segmentation and add comments

The DINOv2 model used in this project is originally developed by Facebook AI and can be found at facebookresearch/dinov2.

Requirements

All the dependencies can be installed using the provided requirements.txt file.

Installation

  1. Clone the repository:

    git clone https://github.com/itsprakhar/Downstream-Dinov2
    
  2. Change the directory:

    cd Downstream-Dino-V2
    
  3. Create a conda environment and install dependencies:

     conda create --name dinov2 --file requirements.txt
    
  4. Activate the conda environment:

    conda activate dinov2
    

Calssification Usage

Prepare your dataset and place it in the data/train directory. The data should be structured such that each class has its own subdirectory containing the respective images. Run the training script with:

python train_classifier.py

Note: This will use the smallest DinoV2 model to use any other, you can change this part in the train_classifier.py code

model = Classifier(num_classes) # this will load the small model
# model = Classifier(num_classes, backbone = 'dinov2_b') # to load the base model
# model = Classifier(num_classes, backbone = 'dinov2_l') # to load the large model
# model = Classifier(num_classes, backbone = 'dinov2_g') # to load the largest model

This will train the model for 100 epochs (modifiable in the script), using the DINOv2 model as a feature extractor and a custom classifier. The training process includes data augmentation, training/validation splitting, and early stopping.

Demo

A demo notebook is provided to guide you on how to use the trained model to classify images. The notebook demonstrates how to load the model, preprocess an image, and perform inference. Check out the demo.ipynb file in the repository.

License

DINOv2 code and model weights are released under the CC-BY-NC 4.0 license. See LICENSE for additional details.

Contact

Prakhar Thakur - [email protected]

Project Link: https://github.com/itsprakhar/Downstream-Dinov2

Please ⭐ if you find it useful so that I find the motivation to keep improving this. Thanks

downstream-dinov2's People

Contributors

itsprakhar 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.