WestonV / RJI-Image-Classifier

Machine Learning Image Classifier Designed to Help Journalists and Photographers
MIT License
2 stars 0 forks source link

BUG: Add classifier scores to image metadeta #14

Open WestonV opened 5 years ago

WestonV commented 5 years ago

We have tried to implement code that adds the ranked image score to the metadata of the photo. We are using a photo metadata tool known as exiftool from this website.

This tool allows you to perform CRUD operations on the metadata of the photos. This is something that Ed McCain wanted, and something that we are close to implementing. However, we have ran into a bug that won't allow us to do it.

I've created a shell script that performs the commands of adding a rating to the metadata of the photo. This shell script takes in the rating and photo path as parameters, and uses those in conjunction with the exiftool commands to modify the photo metadata. This shell script works, and I've tested in extensively.

The issue I'm running into is calling the shell script in our php code. I'm using the php function shell_exec() to execute the bash script. This is happening when each score is being displayed on our display page. The entire block of code looks like this:

 foreach ($json as $images => $image) {   
      $score = $image['mean_score_prediction'];   
      $name = $image['image_id'];   
      //add exiftool rating to photo.   
      shell_exec("./addExifScore.sh $score ($pwd)/uploads/$name.jpg");    
      $stmt->execute();    
   }

For whatever reason, this function is not being executed properly. We know that the script works, as I've been testing it from both server side and local side. There are no issues when I run the script through the command line. This leads me to believe the issue has to be in the php code, and more specifically, the paths. I have tried playing with the paths a lot, however, to no avail. I'm not sure what the error is.