factored out the edge detection part
added code for model pyramid