Click here to Skip to main content
15,608,404 members
Articles / Containers / Docker
Posted 30 Nov 2022


1 bookmarked

How to Use a Custom Model in CodeProject.AI Server in Docker

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
30 Nov 2022CPOL2 min read
This article is a step by step guide on how to run a custom model folder in Docker using CodeProject.AI Server.

If you're running CodeProject.AI Server in a Docker container and want to use a custom model for your detections, this article will show you to take a custom model, and use Docker Desktop to launch the CodeProject.AI Server image with a custom model folder.

First, get the custom model. I decided to use this critters model recently used in our article, How to Train a Custom YOLOv5 Model to Detect Objects. Download the zip folder, extract the file, and then copy this file into the directory C:\MyCustomModels. One quick note: If you want to use this model yourself, make sure you’re running CodeProject.AI Server 1.6.9 and above.    

Next, open Docker Desktop. I've already downloaded the image for CodeProject.AI Server, so if you've missed that step, check out my article on How to Run CodeProject.AI Server in Docker.

Image 1

Go to the Images tab. The codeproject/ai-server image is listed there. Click on the Run button.

Image 2

Then in the Optional Settings dropdown, input 32168 for the Host port, then in the Volumes section, use the three dot dropdown to select your C:\MyCustomModels folder, the hit Select Folder. Then in the Container path, input /app/AnalysisLayer/ObjectDetectionYolo/custom-models. Hit Run.

Image 3

Go back to the Containers tab, and click 32168:32168 to open CodeProject.AI Server. Then click Open CodeProject.AI Explorer.

Image 4

From here, the critters model is now visible in the dropdown. Let's test it!   

This model detects raccoons, so I downloaded a picture of a raccoon from Wikipedia. In the Custom Object Detection window, hit Browse, choose the raccoon image, then hit Run Detection.

Image 5

And that's it! The custom model folder is now running in the CodeProject.AI Server container, and working.   

Alternatively, you can do all this from a command prompt. Go to the Windows start button and type CMD. Launch the command prompt and type:   

docker run -p 32168:32168 --name CodeProject.AI-Server -d -v C:\ProgramData\CodeProject\AI:/usr/share/CodeProject/AI --mount type=bind,source=C:\MyCustomModels,target=/app/AnalysisLayer/ObjectDetectionYolo/custom-models,readonly codeproject/ai-server


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Writer CodeProject
Canada Canada
Sean Ewington is the Content Manager for CodeProject.

His background in programming is primarily C++ and HTML, but has experience in other, "unsavoury" languages.

He loves movies, and likes to say inconceivable often, even if it does not mean what he thinks it means.

Comments and Discussions

-- There are no messages in this forum --