Skip to main content

Finetuner allows one to tune the weights of any deep neural network for better embedding on search tasks.

Project description

Finetuner logo: Finetuner allows one to finetune any deep Neural Network for better embedding on search tasks. It accompanies Jina to deliver the last mile of performance-tuning for neural search applications.

Finetuning any deep neural network for better embedding on neural search tasks

Python 3.7 3.8 3.9 PyPI

Finetuner allows one to tune the weights of any deep neural network for better embeddings on search tasks. It accompanies Jina to deliver the last mile of performance for domain-specific neural search applications.

🎛 Designed for finetuning: a human-in-the-loop deep learning tool for leveling up your pretrained models in domain-specific neural search applications.

🔱 Powerful yet intuitive: all you need is finetuner.fit() - a one-liner that unlocks rich features such as siamese/triplet network, metric learning, self-supervised pretraining, layer pruning, weights freezing, dimensionality reduction.

⚛️ Framework-agnostic: promise an identical API & user experience on PyTorch, Tensorflow/Keras and PaddlePaddle deep learning backends.

🧈 DocArray integration: buttery smooth integration with DocArray, reducing the cost of context-switch between experiment and production.

How does it work

Python 3.7 3.8 3.9

Install

Requires Python 3.7+ and one of PyTorch(>=1.9) or Tensorflow(>=2.5) or PaddlePaddle installed on Linux/MacOS.

pip install finetuner

Finetuning ResNet50 on CelebA

  1. Download CelebA-small dataset (7.7MB) and decompress it to './img_align_celeba'. Full dataset can be found here.
  2. Finetuner accepts docarray DocumentArray, so we load CelebA image into this format using a generator:
    from docarray import DocumentArray
    
    # please change the file path to your data path
    data = DocumentArray.from_files('img_align_celeba/*.jpg')
    
    
    def preproc(doc):
        return (
            doc.load_uri_to_image_tensor(224, 224)
            .set_image_tensor_normalization()
            .set_image_tensor_channel_axis(-1, 0)
        )  # No need for normalization and changing channel axes line if you are using tf/keras
    
    
    data.apply(preproc)
    
  3. Load pretrained ResNet18 using PyTorch/Keras/Paddle:
    • PyTorch
      import torchvision
      resnet = torchvision.models.resnet50(pretrained=True)
      
    • Keras
      import tensorflow as tf
      resnet = tf.keras.applications.resnet50.ResNet50(weights='imagenet')
      
    • Paddle
      import paddle
      resnet = paddle.vision.models.resnet50(pretrained=True)
      
  4. Start the Finetuner:
    import finetuner as ft
    
    tuned_model = ft.fit(
        model=resnet,
        train_data=data,
        loss='TripletLoss',
        epochs=20,
        device='cuda',
        batch_size=128,
        to_embedding_model=True,
        input_size=(3, 224, 224), # for keras use (224, 224, 3)
        freeze=False,
    )
    

Support

Join Us

Finetuner is backed by Jina AI and licensed under Apache-2.0. We are actively hiring AI engineers, solution engineers to build the next neural search ecosystem in opensource.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finetuner-0.4.2.dev6.tar.gz (59.1 kB view details)

Uploaded Source

File details

Details for the file finetuner-0.4.2.dev6.tar.gz.

File metadata

  • Download URL: finetuner-0.4.2.dev6.tar.gz
  • Upload date:
  • Size: 59.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.22.0 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/18.0.1 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.10

File hashes

Hashes for finetuner-0.4.2.dev6.tar.gz
Algorithm Hash digest
SHA256 308a0305e3e207593b8a662cc95320287a11ee663d24a2688b51c1c6919dce37
MD5 1827f98ee76e3430486b897a85269623
BLAKE2b-256 4dcea27ecfa6f90e612dba7db17f78de22af530082e27e6c2f856df1e8559923

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page