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:
- Install the
speedygui
package:
pip install speedygui
- Navigate to the
examples
directory:
cd /path/to/speedygui_project/examples
- 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:
- Install the
briefcase
package:
pip install briefcase
- Make any adjustments to the
/pyproject.toml
file or leave as defaults - Test the application by running:
briefcase dev
- Create your application by running:
briefcase create
- Build your application by running:
briefcase build
- Run your application with:
briefcase run
- Package your app by running:
briefcase package
This will create a msi file in thedist
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
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
Built Distribution
Hashes for speedygui-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34861a51170321d5a19d9009fb684aac487989556e85e4a64a5794bc21d68082 |
|
MD5 | 7d12fc0c1311f9905b50691c836c71c6 |
|
BLAKE2b-256 | de591c64da7fad9d672fa3559ea3decbdaea3c975df9fddc85f8925b38ea3ebf |