I have a use case where I am supposed to get the coordinates of each block element in a page (whether its paragraph, image, table) where I train a model to understand how they are placed in a given page where some documents are with good layout and other with bad ones and I want to train this and throw in some coordinates of a new document and try to understand whether it has a good layout or a bad layout, I want to understand how I can achieve this using some deep learning techniques ?

can someone suggest me an approach for solving this?

Was trying to workout with RNN but not sure if that's the correct approach.

  • $\begingroup$ This depends very much on what kind of data you have, are all the documents of the same type (e.g all CV's). Furthermore is there any specific reason you want an RNN, would a random forest not do just as well (you'd need to do some feature engineering to extract good data for it though). $\endgroup$
    – Tasty213
    Aug 21, 2019 at 12:29
  • $\begingroup$ Yes, all the documents are of the same type, Not exactly which one would be doing good so was asking for a recommendation. What kinds of features would be helpful for building the system? $\endgroup$ Aug 21, 2019 at 12:31
  • $\begingroup$ This would depend on how you want to decide whats a good layout or not. I would imagine maximum, minimum and average font height, the type of the first through too however many is most effective objects on the page, names of headings, page margin sizes etc $\endgroup$
    – Tasty213
    Aug 23, 2019 at 13:02
  • $\begingroup$ Got it but what approach would be better for a model generation? like which one is preferred? $\endgroup$ Aug 26, 2019 at 9:05
  • $\begingroup$ I'd probably do both, train an series of ML models and if they perform well enough stop. If you need more accuracy try a Multi layer perceptron then full AI $\endgroup$
    – Tasty213
    Aug 27, 2019 at 10:25

1 Answer 1


When you're talking about layout, I am assuming you are talking about the way elements are arranged in the page. In that case, dividing your page into grids and having each element represented into grid numbers should solve your problem. Let's assume your page is divided into 9 x 9 grids, then you can have this data frame as an input. Grids can be replaced with your co-ordinates. You can add in more features like font-size, font-style, colour, etc.,

number header1 header2 header3 paragraph1 font-size-h1 font-size-h2 target
1      (2,3)      4     (4,2)     3           12           8           0

The tuple represents the co-ordinates and the individual number represents the grid number. The font-size can be added for each element which will increase the dimensions of the dataset. May be try running a simpler algorithm like Random Forest first and then move onto deep learning techniques. Sometimes, simpler algorithms work better than complex algorithms.

Aesthetic Value of a Webpage, Layout Classification

  • $\begingroup$ But i will never be able to figure out the exact number of headers or paragraphs and make it same all the time as for each and every page they change.so how do i deal with that? and should we not consider the way they are layed out i mean the sequence of which the elements are on the page ? $\endgroup$ Aug 30, 2019 at 5:50
  • $\begingroup$ Good point. I didn't really consider the fact about changing number of headers and different styles. Have you considered using them as images and running convolutional neural networks on them? They should be able to extract specific spatial features. Is your analysis purely based on aesthetics? $\endgroup$
    – Danny
    Aug 30, 2019 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.