
Switch off the GPU in a Python script
Posted 28th October 2024
No comments
Here’s a simple piece of code which effectively directs a Python script to use the CPU rather than the GPU.

Divide Label Studio YOLO annotation files into training and validation sets
Posted 17th October 2024
No comments
Label Studio is an open-source data-labelling platform used to prepare training data for machine learning models.

Download and extract a tarball in Python
Posted 9th October 2024
No comments
A simple method for downloading a tarball from the internet and then extracting its contents in Python.

Crop images in Python with array indexes
Posted 22nd May 2024
No comments
The advantage of this simple procedure for image cropping is that there’s no need to install special image manipulation packages.

Jupyter Notebook in Windows Subsystem for Linux (WSL)
Posted 24th October 2023
No comments
Here’s a procedure for enabling Jupyter Notebooks to run on a Windows brower from a Linux environment on the same machine.

Flattening nested lists or arrays in Python
Posted 2nd June 2023
No comments
There may be a requirement to flatten a list of lists in Python in order to extract useful information more easily. Here’s a procedure for flatting nested lists using NumPy.

Batch rename files using a CSV in Python
Posted 19th January 2023
No comments
Use this simple Python script to change hundreds or thousands of file names automatically, based on a CSV. This procedure will work on all operating systems.

List directory contents in CSV file using Python
Posted 18th January 2023
No comments
Do you need to compile a list of all of the files in a folder or directory? This can be automated using a simple Python script which will save a list of the files (and their full paths) into a CSV file that can be read in Excel.

Structuring elements in Python
Posted 1st September 2022
1 comment
Some simple methods to generate structuring elements as part of an image morphology pipeline in Python.

Add your Conda environment to your Jupyter Notebook
Posted 31st May 2022
No comments
By default, Jupyter Notebook will only display a single kernel (called ipykernel) when installed in a new environment. Here’s a procedure for choosing another Conda environment in a Jupyter Notebook.