AI Image Generation work by using deep learning and algorithms. There is also a large data set present. This data set would help recognize patterns and elements so the generated image matches what you want.