title: How to return image and json in one response in fastapi?
body: <p>I get an image, change it, then it is classified using a neural network, should return a new image and json with a response. How to do it with one endpoint?
  image is returned with Streaming Response but how to add json to it?</p>
  <pre><code>import io
  from starlette.responses import StreamingResponse
  
  app = FastAPI()
  
  @app.post(&quot;/predict&quot;)
  def predict(file: UploadFile = File(...)):
      img = file.read()
      new_image = prepare_image(img)
      result = predict(new_image)
      return StreamingResponse(io.BytesIO(new_image.tobytes()), media_type=&quot;image/png&quot;)
  </code></pre>