title: How to crawl image from using url?
body: <p>I am trying to extract the images from url by below python code but after extraction, at last point, I am getting the following error:</p>
  <pre><code>OpenCV(4.1.2) /io/opencv/modules/imgcodecs/src/loadsave.cpp:715: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'
  </code></pre>
  <p>how to remove this error.</p>
  <p>Python code is:</p>
  <pre><code> import sys
      import requests 
      from bs4 import BeautifulSoup
      import time
      import base64
      import numpy as np
      import cv2
      url='https://thispersondoesnotexist.com/image'
      headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
      imgs = {}
      
      for i in range(1,10):
          res=requests.get(url,timeout=60,headers=headers)
         
          imgs[i]=res.content
      
          jpg_original = base64.b64decode(res.content)
          jpg_as_np = np.frombuffer(jpg_original, dtype=np.uint8)
          img = cv2.imdecode(jpg_as_np, flags=1)
          cv2.imwrite('./0.jpg', img)
          time.sleep(5)
  </code></pre>