Skip to main content

Check whether your plants are healthy using image classification

Project description

Multi Scale Expansion

Repository to create framework for image classification computer vision models in tensorflow.
image image Build Status codecov

Overview

multi-scale-expansion is a library for automating the set up of an image classification model. The user provides their data, and the library creates and trains a ready-to-use model to complete the image classification task and apply it to any image further. The objective is that this framework can be automated and applied for recognizing whether a plant is healthy or not, through the use of the models we train.

Contributions

For instructions on how to contribute, go to the Contribution Guidelines Page.

Installation

Prerequisites:

  • Python >= 3.7
  • Torch & Torchvision
  • Numpy
  • Matplotlib
  • PIL (Pillow)

To install Python packages:

$ pip install torch
$ pip install torchvision
$ pip install numpy
$ pip install matplotlib
$ pip install Pillow

To install library:

$ pip install multi-scale-expansion

Quick-Start Example

import torch
from torchvision import models
import numpy as np
import matplotlib
from PIL import Image
import importlib

ms_model = importlib.import_module("multi-scale-expansion.model")
ms_datasets = importlib.import_module("multi-scale-expansion.dataset")
ms = importlib.import_module("multi-scale-expansion.classification")

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
mock_model = models.resnet18(weights='DEFAULT')
mock_model = ms_model.get_plant_model(mock_model, list(range(6))

mock_lr = 0.001
mock_momentum = 0.9
mock_step_size = 7
mock_gamma = 0.1
mock_criterion, mock_optimizer, mock_lr_scheduler = get_train_loss_needs(
    mock_model, mock_lr, mock_momentum, mock_step_size, mock_gamma
)

mock_datasets = {
    "train": FakeData(num_classes=6, transform=mock_transforms["train"]),
    "test": FakeData(num_classes=6, transform=mock_transforms["test"]),
}

mock_dataset_sizes = {x: len(mock_datasets[x]) for x in ['train', 'test']}
mock_dataloaders = ms_datasets.get_dataloaders(mock_datasets)

model, train_losses, train_accuracies, val_losses, val_accuracies = ms.train_model(
    device,
    mock_dataset_sizes,
    mock_dataloaders,
    mock_model,
    mock_criterion,
    mock_optimizer,
    mock_lr_scheduler,
    num_epochs=1,
    testing=True,
)

And now your model is ready-to-use!

Project details


Download files

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

Source Distribution

multi-scale-expansion-0.1.1.tar.gz (11.8 kB view details)

Uploaded Source

File details

Details for the file multi-scale-expansion-0.1.1.tar.gz.

File metadata

  • Download URL: multi-scale-expansion-0.1.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/6.0.0 pkginfo/1.9.6 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.64.1 CPython/3.10.9

File hashes

Hashes for multi-scale-expansion-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d2fe80d212bca6ba1b0ba60c93c5c70d5856eedb577c30f58f35b26a60bc22cd
MD5 7422a7579e543494cceb9a80b124578f
BLAKE2b-256 52b84a6a754b6c1426c02cc653fe952a327861fd494f4ff1665152007e9f19bc

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