Transform interface design mockups into ready-to-use UI code with these AI-based tools
Tags: interface, mockup, ai, design
Published: 2020-01-08 14:46:28

No programmer wants to spend hours aligning HTML elements or playing with complex CSSs. This is why any <a href="https://modeling-languages.com/low-code-platforms-new-buzzword/" target="_blank" rel="noopener noreferrer">low-code tool</a> will generate the User Interface code of your application for you. The problem is that they generate rather basic interfaces, mostly oriented to typical data-entry forms and grids. Anything more complex than that and you are back to tuning the CSS by hand.

On the opposite spectrum, we have a variety of <a href="https://www.indiehackers.com/forum/what-is-your-go-to-visual-prototyping-tool-d2627cc95f" target="_blank" rel="noopener noreferrer">visual mockup/wireframe tools</a> to quickly build a prototype of your desired graphical interface. But those don't include any kind of code-generation capabilities. Therefore, you enter a vicious cycle where <em>"the designer prepares an app design, hands it off to the developer who manually codes each screen. This is where the back and forth starts (colors, responsive layouts, buttons, animations...). In some cases, this process can take weeks or months" </em>(taken from <a href="https://techcrunch.com/2018/03/13/supernova-studio/" target="_blank" rel="noopener noreferrer">here</a>).

To fix this situation, a few design-to-code tools started to appear. For instance, <a href="https://supernova.io/" target="_blank" rel="noopener noreferrer">Supernova</a> takes <a href="https://www.sketch.com/" target="_blank" rel="noopener noreferrer">Sketch</a> designs and transforms them into ready-to-use native UI code. <a href="https://www.yotako.io/" target="_blank" rel="noopener noreferrer">Yotako</a> also aims to help you in a smooth transition from design to code.

But, as in many other fields, the arrival of the new AI era has boosted the number and functionality of these tools (note that, for the same reason, most are still in early/exploratory stages). The promise of these tools is that they can <strong>use as the input of the UI code generation process screenshots and even handmade sketches.</strong> Thanks to the use of deep learning technologies to recognize the interface elements in the images, they can grasp the desired UI and generate the code that will mimic that design (either by going from the rough sketch to a "formal" wireframe or by directly generating the code). Let's see some of these tools / approaches
<h2 class="elementor-heading-title elementor-size-default">Viz2&lt;code&gt;</h2>
<a href="http://viz2code.tech/" target="_blank" rel="noopener noreferrer">Viz2&lt;code&gt;</a> is still in beta but it looks very promising. You can use as input a "standard" wireframe design or handmade sketches and export them to Sketch files or a ready to launch website. If the latter, they also promise to generate for you some useful code that helps you integrate that front-end with your data and backend.

They use deep neural networks to recognize and characterize components when scanning the design. Then they try to infer the role and expected behavior of each recognized component to generate a more "semantic" code.

Viz2&lt;code&gt; is the tool featured in the top image illustrating this post.
<h2>AirBnB Sketching Interfaces</h2>
<a href="https://airbnb.design/sketching-interfaces/" target="_blank" rel="noopener noreferrer">This experiment</a> from AirBnB aimed mainly at detecting visual components on rough sketches. Their point was that "if machine learning algorithms can classify a complex set of thousands of handwritten symbols  with a high degree of accuracy, then we should be able to classify the 150 components within our system and teach a machine to recognize them". 

They trained the system with the set of components they typically use in AirBnB interfaces and managed to get a high degree of recognition.

Unfortunately, it looks this was mainly and exploratory experiment. Even the main person behind it has moved to another company so not sure what the future plans for this is.

<h2>Uizard pix2code</h2>
<a href="https://uizard.io/research/" target="_blank" rel="noopener noreferrer">Uizard's</a> vision is to improve the designer/developer workflow that too often results in more frustration than innovation. They have recently <a href="https://techcrunch.com/2019/09/09/uizard/" target="_blank" rel="noopener noreferrer">raised 2.8M in seed funding</a> to quickly turn app sketches into prototypes. Even if there are plenty of tools to specify the mockups of a new product, more often than not, any meeting ends up with a few quick hand-sketches. Their goal is to turn them into prototypes in seconds. The public version of their Sketch2code solution is <a href="https://github.com/tonybeltramelli/pix2code" target="_blank" rel="noopener noreferrer">pix2code</a> (but they have a better commercial version).<a href="http://modeling-languages.com/wp-content/uploads/2019/11/uizard_tech_overview.png"><img class="aligncenter wp-image-7283" src="https://modeling-languages.com/wp-content/uploads/2019/11/uizard_tech_overview.png" alt="" width="717" height="448" /></a>
<h2>Screenshot to Code</h2>
This <a href="https://github.com/emilwallner/Screenshot-to-code" target="_blank" rel="noopener noreferrer">open-source project</a> reuses some of the ML above (especially pix2code) to create an <a href="https://medium.com/@emilwallner/how-you-can-train-an-ai-to-convert-your-design-mockups-into-html-and-css-cc7afd82fed4" target="_blank" rel="noopener noreferrer">excellent tutorial</a> you can use to learn (and play) with all the ML concepts and models you need to get your hands into this mockup to UI field.
<h2>Microsoft's Sketch2Code</h2>
<a href="https://www.ailab.microsoft.com/experiments/30c61484-d081-4072-99d6-e132d362b99d" rel="nofollow">Sketch2Code</a> is a Microsoft approach that uses AI to transform a handwritten user interface design from a picture to valid HTML markup code. Sketch2code involves three main "comprehension" phases.
<ol>
 	<li>A custom vision model predicts what HTML elements are present in the image and their location.</li>
 	<li>A handwritten text recognition service reads the text inside the predicted elements.</li>
 	<li>A layout algorithm uses the spatial information from all the bounding boxes of the predicted elements to generate a grid structure that accommodates all.</li>
</ol>
The result as you can see is quite impressive.

<a href="http://modeling-languages.com/wp-content/uploads/2019/11/S2C_Homepage-Carousel.gif"><img class="aligncenter size-full wp-image-7284" src="https://modeling-languages.com/wp-content/uploads/2019/11/S2C_Homepage-Carousel.gif" alt="Sketch2code by Microsoft" width="580" height="326" /></a>

<a href="https://www.microsoft.com/en-us/garage/profiles/ink-to-code/" target="_blank" rel="noopener noreferrer">Ink to code</a> was an earlier and much more experimental attempt.
<h2>Generating interface models and not just code</h2>
I would like to see some of these tools generating not the actual code but <strong>the models of that UI</strong> so that it would be possible to integrate those models with the rest of the software models within a [low-code tool](https://modeling-languages.com/big-five-bet-modeling-low-code/). This way, we could easily link and integrate with UI components with the rest of the system data and functionality and generate at once a complete implementation.