Application to transform camera photo into cartoon image.
In previous articles I developed a web based object detection system using YOLO and a text recognition application using Tesseract. In this article let’s build a fun cartoon camera which transforms camera photo into cartoon image.
The is a web based application built using React and FastAPI. The frontend application uses the web camera to capture photo and send to the backend through web socket. The backend application transforms it into a cartoon image, and sends the cartoon image back to the web application.
There are different styles that you can apply to the image. Below is a snapshot of a transformed photo.
The backend is built using FastAPI. It hosts APIs to serve CartooGAN: Generative Adversarial Networks for Photo Cartoonization using HTTP and web socket.
You can access the APIs using FastAPI built-in Swagger UI at http://localhost:8088/docs.
Below is the image used to test the API, using the Swagger UI.
And below are the images with different cartoon styles.
For details on how the backend is built and debugged, you can refer to the following articles.
Serving Machine Learning Models (DCGAN, PGAN, ResNext) using FastAPI and Streamlit
Frontend Web Application
Frontend is a web application built using React. It uses the web camera to take photo and send captured image to the backend through web socket. For technical implementation you can refer to the articles mentioned above.
With the provided pre-trained models, it is relatively easy to host them using FastAPI and React. You can find the source code for this application from this repository.
Do check out the following articles!
Object Detection and Segmentation using Detectron2
Python application for real time object detection and segmentation.