# Pass the image through the first layer results = [all_layers[0](img)] # Pass the results of the previous layer to the next layer for idx in range(1, len(all_layers)): # Start at 1, first layer already passed! results.append(all_layers[idx](results[-1])) # Pass the last result to the layer