![](https://crypto4nerd.com/wp-content/uploads/2023/08/1yU7x4nwg-NReauWvyEHTHA-1024x295.png)
Why I am interested in this project
Apart from being a data analyst, I am also a woodworking enthusiast. For someone who is not good at wood carving is better to have some draft for reference. But for someone who is not good at drawing … We need some painting and glue on the wood to start carving.
That’s why I am trying to find out how can I transform images into line drawings.
There are a few ways to do the job
Advantage
- You can fine-tune your drawing until it’s just right. Plus, it’s like having an eraser for real life!
Disadvantage
2. Convert Using python with a simple transformation
Advantage
- Free
- Transform with batch size
Disadvantage
- Hard to fine-tune
- Some photos perform badly
3. Using some AI convert from the Internet
Advantage
Disadvantage
- Cannot control the result
- Need to pay for it.
Let’s see the result of convert using OpenCV
It seems that some of the photos with clear contrast and line may transform well, but some photos with different focal may performance bad.
I wonder if can I use some machine learning to train my model for transformation that brings better results. And I have some ideas want to test for :
- Pick some clear views by Python convert, train a CNN model and see the performance of inputting complex photo
- Using Transfer Learning. try to transfer the photo to black and white style
Training a CNN model
Before customizing the sample photo, I want to test if the model can learn the process of converting. I plan to use OpenCV to convert photos to draw lines. put into a machine learning model and test how it learns on it.
As it didn’t need classification, I decide not to add some layers like max-pooling that will affect dimension.
Although it was an easy photo of the convert, the model learning of model is still impressing me!
I am wondering if I have made some custom edits to the training set, well it performs better?
I have prepared around 200 custom images to train a new model.
While the dataset is not enough. I decide to train more than one’s time
I have attempted to enhance the model’s performance by incorporating max-pooling layers, which allow the model to better discern objects from the background. However, the impact on performance doesn’t seem to be substantial.
What is your assessment of the current performance? In my view, the model’s performance is quite satisfactory; the contours are displayed more distinctly. Nonetheless, it’s worth noting that preparing the training set demands a significant amount of time, as each piece needs to be edited individually. Additionally, given the scale of my dataset, the model might struggle to effectively eliminate the background.
The task of preserving only the main contours while eliminating the background proves to be challenging for this particular model. Hence, it might be prudent to explore alternative approaches.
Neural style transfer
One such approach is neural style transfer. In the Tensorflow hub, there are pre-built models designed for neural style transfer. I hold the belief that developing a new model might be unnecessary and unlikely to yield performance improvements within the current model’s framework.
Let’s evaluate the performance of the transfer process using two distinct line drawing styles as the style images.
Comparing the outcomes, it’s evident that while style transfer can capture the contours, it tends to omit finer details such as veins within the image. Furthermore, the veins often adopt the characteristics of the style image. Additionally, depending on the specific objects, the drawing might also incorporate the texture of those objects. Considering these factors, it appears that utilizing a CNN model might be a more suitable option.
Summary
through our analysis, it’s apparent that the model has made significant advancements in performing conversion tasks. To further enhance the results, an essential step is to augment the training dataset with more samples.