Setup Env(MASK R-CNN)
Setup environment of mask R-CNN Run using Tensorflow 2.0.0 on Windowns using Docker and WSL¶
This tutorial walks through setting up Mask R-CNN
using TensorFlow 2.0
on a Windows system with Docker and Windows Subsystem for Linux (WSL)
. By leveraging Docker, you avoid complex CUDA
installations and ensure portability across systems.
Step 1: Activate WSL and Install Ubuntu¶
- There are two ways to activate WSL and install Ubuntu:
Option 1: Enable WSL via PowerShell¶
Open PowerShell as Administrator.
Run the following command:
wsl --install
When prompted, choose
Ubuntu
as your Linux distribution.
Option 2: Install Ubuntu
from Microsoft Store
¶
Open Microsoft Store on Windows.
Search for
Ubuntu
and install the latest version.Launch
Ubuntu
and complete the initial setup.
Step 2: Install Docker and Set Up TensorFlow Container¶
Install Docker Desktop from Docker's official website.
Open
Ubuntu
and run the following command to pull theTensorFlow Docker image
with GPU support:Verify that the image is available by checking Docker Desktop under
Images
.
Step 3: Set Up VS Code with Docker & Dev Containers¶
Open
Visual Studio Code
.Install the following extensions (
Ctrl+Shift+X
→ Search → Install):Dev Containers
Docker
Attach VS Code to the TensorFlow container:
- Press
F1
, typeRemote-Containers: Attach to Running Container
, and select theTensorFlow container
.
- Press
Step 4: Load the Kangaroo Transfer Learning Project¶
In
VS Code
’s terminal, add the Kangaroo Transfer Learning folder to your workspace:
Step 5: Update & Install Dependencies¶
Open the
requirements.txt
file in the project directory.Modify package versions if needed.
Install dependencies inside the
Docker container
:pip install -r requirements.txt
Step 6: Download Pre-Trained Weights¶
Download the
mask_rcnn_coco.h5
file fromMask R-CNN 2.0
.Place the file in the appropriate project folder.
Step 7: Run the Kangaroo Training Script¶
Navigate to the project directory:
cd kangaroo_transfer_learning
Start training:
python3 kangaroo_training.py
Step 8: Test Model with a Sample Image¶
Locate an image in /kangaroo/images.
Rename the selected image to sample2.jpg.
Run the prediction script to evaluate the model:
python3 kangaroo_prediction.py
Troubleshooting Common Issues¶
❌ ImportError:
libGL.so.1
Not FoundFix by running:
pip uninstall opencv-python pip install opencv-python-headless
Conclusion¶
By using Docker for machine learning, you achieve a reproducible, scalable, and efficient workflow for deep learning applications. With WSL and VS Code integration, developers can seamlessly train models while maintaining the flexibility of Linux and Windows environments.
🚀 Happy coding! 🖥️🐍📦