clarifai-php
clarifai-php copied to clipboard
Send Multiple Images in one call with IDs
I am trying to send multiple images with just one api call, but the result is a empty json foreach image I sent.
The code that I am using is:
foreach ($imagBase64 as $key => $imgbase64) {
$input[$key] = new DarrynTen\Clarifai\Entity\Input();
$input[$key]->setImage($imgbase64)->isEncoded()->setId($key);
}
$inputResult = $clarifai->getInputRepository()->add($input);
$inputResult = $clarifai->getInputRepository()->get();
$results = json_decode(json_encode($inputResult));
var_dump($results);
If I send each image in an individual API Call using the following code I get the result:
foreach ($imagBase64 as $key => $imgbase64) {
$modelResult[$key] = $clarifai->getModelRepository()->predictEncoded(
$imgbase64, \DarrynTen\Clarifai\Repository\ModelRepository::GENERAL
);
}
foreach ($modelResult as $key => $result) {
$image[$key] = json_decode(json_encode($result));
}
What I am doing wrong? I think maybe I need to set a ModelRepository, but I don't find a funtion to do this in documentation.