Quantitative control of flow rate using deep learning

Advanced Intelligent Systems

Advanced Intelligent Systems


June 10, 2023

3D printing creates objects by depositing layers of material on a platform. It has the potential to revolutionise manufacturing by allowing local and customised production of complex and novel products. However, 3D printing is prone to errors, such as over-extrusion or under-extrusion of material, or misalignment of layers. These errors can compromise the quality and functionality of the printed objects and require human intervention or post-processing to fix. We aim to make 3D printing more reliable and efficient by using artificial intelligence (AI) to detect and correct errors in real time.

In this particular work, we used a camera to monitor the 3D printing process, especially the material coming out of the printer nozzle. And also collected some data from the printer itself, such as the speed and position of the nozzle and the rate at which material is being extruded (fig. 1). We did this for different printed shapes and patterns, and for different extrusion rates. This produced over 250,000 images, each with a label of the extrusion rate active at the time. The images were cropped to focus on the nozzle area. During the training, the images were also changed slightly to make them more varied. We did this by adjusting the colours, flipping them horizontally, and cropping them randomly (fig. 2). 

Fig. 1: Data collection process for a range of flow rates across single-layer geometries.

This data was then used to train an AI system that can predict the optimal material flow rate for each layer, and how to adjust it if it deviates from the desired value. We used a type of model called a RegNet that was already good at recognizing objects in pictures, and used it to predict the flow rate from the images. This predicted adjustment can then also be used to modify the printer settings quickly and automatically based on the machine learning model’s feedback. In this way, the printer can adapt to its own errors and correct them before they accumulate and affect the final outcome.

Fig. 2: Data augmentation procedure

Fig. 3 shows the range of flow rates that we used for training. The prediction errors are also plotted, showing that they are mostly small and centred around zero. The smallest AI model we tested could make 100 predictions per second on a single computer chip, which is much faster than the camera or the printer. This means that we could use it for multiple printers at once or combine it with other programs to make it even better. We also used some methods to make the predictions smoother and more reliable, especially for new prints that are different from the ones we trained on. These are described in more detail in the full paper.

Fig. 3: Results of trained model on unseen test set (A), test time cropping procedure (B).

An important challenge for any AI model is testing it on something it has not seen before. We tested our system on a new material (foaming PLA) that changes its shape and size when it is printed. The amount of foaming depends on the temperature of the printer, and this affects how much material we need to use. We did not know how to adjust the flow rate for this material before testing, so we let our system learn it by itself. A test part with foaming PLA was printed and the temperature changed every 20 mm. As expected, the shape of the foaming material changed with the temperature. We used our camera and AI model to predict the flow rate for each temperature, and we saw that they matched what we observed. The program could tell when the material was under-extruded or over-extruded, and what was the best flow rate for this material (Fig. 4). Here, we also used our system to control the printer automatically and adjust the flow rate in real time, observing that the system could correct the errors quickly and make a smooth and accurate print. Our AI system printed a part with foaming PLA and controlled the flow rate automatically. The printing process was imaged using the nozzle-mounted camera, and these images were sent to our program to get the predictions. These predictions were used to calculate how much we needed to change the flow rate to make it optimal, and instructions to update the flow rate were then sent to the printer. We also split the printing path into smaller segments to make the printer respond faster. Our system worked well for most of the printing time, keeping the flow rate within a narrow range. Some errors were also seen at the beginning and the end of the printing, where the program had trouble predicting the flow rate because of the shape and position of the material. This could be countered by using more training data for these cases, but these errors are also unlikely to significantly affect the print quality. 

Fig. 4: Self-learning the optimal flow rate for unseen foaming PLA.

Our system was also tested on a part that looks like a spanner. An error was introduced on purpose and the flow rate was reduced to half of what it should be. In the first test, the flow rate was kept constant and the part was very poorly printed (Fig. 5A). We then printed the same part again with the same error introduced, but this time we allowed our system to fix it. Fig. 5b shows that our system could detect and correct the mistake very quickly. Unlike other systems, our system does not need many tries to find the right flow rate, but it can do it in one or a few steps. Our system does sometimes suggest small changes that are not needed. To avoid this, we changed the response speed of the system depending on how close the prediction was to the optimal value. The closer it is, the less urgent the change. We also waited for a short time after making a big change to make sure that the effect was visible before making another prediction. This delay was not too detrimental to part quality because our system usually only needs one change to fix the mistake. 

Fig. 5: Demonstration of rapid online flow rate correction in the first layer of an adjustable spanner.


On the whole, our system was evaluated on different materials and geometries, suggesting that it could improve the speed, accuracy, and consistency in a wide range of 3D printing use cases. Our system could also learn new settings for new materials or geometries in a few trials. This could help 3D printing become more accessible and versatile for producing a wide range of objects. Ultimately, the system could even be extended to other types of manufacturing that use similar data and techniques.

Further Reading


Douglas A. J. Brion

Sebastian W. Pattinson


This work has been funded by the Engineering and Physical Sciences Research Council (EPSRC) Ph.D. Studentship EP/N509620/1 to Douglas Brion, Royal Society award RGS/R2/192433 to Sebastian Pattinson, Academy of Medical Sciences award SBF005/1014 to Sebastian Pattinson, Engineering and Physical Sciences Research Council award EP/V062123/1 to Sebastian Pattinson, and An Isaac Newton Trust award to Sebastian Pattinson. For the purpose of open access, the author has applied a Creative Commons Attribution (CC-BY) license to any Author Accepted Manuscript version arising.