Skip to main content

A simple template for creating GUI PyTorch medical image segmentation applications

Project description

Speedy GUI

Speedy GUI is a Python package that provides a quick template graphical user interface (GUI) for running inference on image segmentation datasets. It allows you to select a folder containing images, run a pre-trained PyTorch model, and save the predicted masks to a specified directory.

https://github.com/justincharney/speedygui/assets/56408885/6a6435fe-3073-4618-a31a-3188ea58eb25

Installation

You can install the package from PyPI using pip:

pip install speedygui

Usage

To use the Predictor GUI, you need to provide the following components:

  • A PyTorch model for prediction
  • A dataset creator function to make a PyTorch Dataset
  • Dataloader keyword arguments
  • A save predictions function to store the outputs
  • An optional output transformation function

Here's a basic example of how to create and run the Predictor GUI application:

from speedygui import Predictor
import torch

# Define your dataset creator function
def dataset_creator(folder_path):
    # ...

# Load your model
model = torch.hub.load('your/model/path', 'model_name')

# Define dataloader keyword arguments
dataloader_kwargs = {
    'batch_size': 1,
    'shuffle': False,
    'num_workers': 0,
}

# Define a save predictions function
def save_predictions_fn(folder_path, predictions, dataset):
    # ...

# Define an optional output transform function
def output_transform(outputs):
    # ...

# Create the Predictor instance
predictor = Predictor(model, dataset_creator, dataloader_kwargs, save_predictions_fn=save_predictions_fn, output_transform=output_transform)

# Create and run the GUI application
app = predictor.create_app('Predictor App', 'org.example.predictor')
app.main_loop() 

Running the Examples

To run the examples, you need to install the example dependencies separately:

  1. Install the speedygui package:
    pip install speedygui
  2. Navigate to the examples directory:
    cd /path/to/speedygui_project/examples
  3. Install the example dependencies:
    pip install -r requirements.txt

You can also use briefcase to create and distribute the app (brain_segmentation). This is based on using windows:

  1. Install the briefcase package:
    pip install briefcase
  2. Make any adjustments to the /pyproject.toml file or leave as defaults
  3. Test the application by running:
    briefcase dev
  4. Create your application by running:
    briefcase create
  5. Build your application by running:
    briefcase build
  6. Run your application with:
    briefcase run
  7. Package your app by running:
    briefcase package
    This will create a msi file in the dist folder

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

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

speedygui-0.1.3.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

speedygui-0.1.3-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

Supported by

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