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 critter.pt, and then copy this file into the directory C:\MyCustomModels. One quick note: If you want to use this critters.pt 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.
Go to the Images tab. The codeproject/ai-server image is listed there. Click on the Run button.
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.
Go back to the Containers tab, and click 32168:32168 to open CodeProject.AI Server. Then click Open CodeProject.AI Explorer.
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.
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
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.