The object detection application has successfully identified and extracted an object from the original image. Below are the original image and the extracted object:
The object detection model has isolated the following object from the original image:
- The object detection model was applied to the original image.
- The model identified a mouse as a distinct object within the image.
- Using the model's output, the mouse was extracted from the original image.
- The extracted object was saved as a separate image file.
This demonstrates the capability of the object detection application to identify and extract items from a complex background, which can be particularly useful in various computer vision tasks such as inventory management, automated checkout systems, or even for preparing datasets for further machine learning tasks.
This guide outlines the steps to build and run a Dockerized application using docker-compose, including specifying the requirements for Python and Docker. Following these instructions will enable access to the application via http://localhost:8000/.
Before you begin, ensure you have the following installed on your system:
- Docker: An open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. Download Docker
- Docker Compose: A tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services. It then creates and starts all the services from your configuration. Docker Compose is included with Docker Desktop.
Your Dockerized application will run in an isolated container, including all necessary Python packages specified in requirements.txt file. Ensure this file is up to date with all the dependencies your Python application needs.
-
Navigate to the Project Directory
Open a terminal and change to your project directory where
docker-compose.ymlis located.cd path/to/computer-vision/risk_manager -
Build and Start Your Application
Use
docker-composeto build and start your application. The--buildoption ensures that Docker builds fresh images, considering any changes made to the Dockerfile or to your application's dependencies specified inrequirements.txt.docker-compose up --build
This command starts the containers defined in your
docker-compose.ymlfile. If you're running the command for the first time, it might take some time to download the required Docker images and build your application's image. -
Accessing the Application
Once the application is running, you can access it by navigating to http://localhost:8000/ in your web browser.
This assumes your
docker-compose.ymlor Dockerfile configures the application to listen on port 8000 and maps this port to the host. -
Shutting Down the Application
To stop and remove the containers, networks, and volumes created by
docker-compose up, use the following command in the terminal:docker-compose down
Ensure your Dockerfile correctly sets up the Python environment, installs dependencies from requirements.txt, and starts your application. This setup is crucial for the application to run successfully in a Docker container and be accessible on http://localhost:8000/.
If you encounter any issues with Docker or Docker Compose, consult the official documentation for troubleshooting and detailed usage instructions:
This guide covers setting up a virtual environment, installing dependencies, and running the predict.py script within the object_detection project. Separate instructions are provided for Windows and Unix-like operating systems (macOS and Linux).
Follow these steps to set up and run the project on Windows:
-
Navigate to the Project Directory
Open Command Prompt and change to the project directory:
cd path\to\computer-vision\object_detection -
Create a Virtual Environment
Run the following command to create a virtual environment named
computer_vision:python -m venv computer_vision
-
Activate the Virtual Environment
Activate the virtual environment by running:
computer_vision\Scripts\activate
-
Install Dependencies
Install the required Python packages from
requirements.txt:pip install -r requirements.txt
-
Run the Prediction Script
Execute
predict.py, which is located in thesrcdirectory:python src\predict.py
Press key Q to stop.
-
Deactivate the Virtual Environment
Once you're done, you can deactivate the virtual environment:
deactivate
For macOS and Linux systems, follow these instructions:
-
Navigate to the Project Directory
Open a terminal and change to the project directory:
cd path/to/computer-vision/object_detection -
Create a Virtual Environment
Create a virtual environment named
computer_vision:python -m venv computer_vision
-
Activate the Virtual Environment
Activate the virtual environment:
source computer_vision/bin/activate -
Install Dependencies
Install the required Python packages:
pip install -r requirements.txt
-
Run the Prediction Script
Run
predict.pylocated in thesrcdirectory:python src/predict.py
Press key Q to stop.
-
Deactivate the Virtual Environment
Deactivate the virtual environment:
deactivate
When running predict.py, the script may attempt to access your computer's webcam for object detection tasks. Ensure that your webcam is properly connected and configured to be accessible by Python scripts. On some systems, you may need to grant permission for webcam access. If the script fails to initialize the webcam, check your system's privacy settings and the script's webcam access code.

