johnolafenwa / DeepStack

The World's Leading Cross Platform AI Engine for Edge Devices
Apache License 2.0
690 stars 108 forks source link

Face-Recon: 400 - no valid image file found #191

Closed seb2010 closed 1 month ago

seb2010 commented 1 month ago

Hello,

I am on Debian Bookworm Linux and running a node.js 18 environment. DeepStack is running as a docker container. I do have issue to reliably send images to the end-point via post-request. No matter what library I try to send the post-data to the recognize-API, I either get a timeout or a 400 - "no valid image file found". What is the issue here?

Can you describe what exact headers and Content there is expected and what I am doing wrong?

const fs = require("fs")
const axios = require("axios")
const FormData= require('form-data')

var image_stream = fs.createReadStream('./somefile.jpg')
var form = new FormData()
form.append('image', image_stream);
axios({
    method: "post",
    url: "http://192.168.178.46:666/v1/vision/face/recognize",
    headers: { 'Content-Type': 'multipart/form-data'},
    data: form,
    timeout: 1000
}).then(function (response) {
   // do some stuff with the response
}).catch(function(error){log(error)})

Hope you can help here. KR SEB

seb2010 commented 1 month ago

Form data preparation caused some headache because of the various and differing methods how to read local files and remote files and to prepare the payload... https://stackoverflow.com/questions/78789251/cannot-post-image-as-a-form-payload-element-to-node-js-api/78795026#78795026