WestonV / RJI-Image-Classifier

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

Add Scoring Functionality #4

Closed antoniomv3 closed 5 years ago

antoniomv3 commented 5 years ago

image

The system must be able to score uploaded photos and display these scores in the gallery.

To accomplish this we have to call the image classifier from the PHP file handling file upload. The results of the classifier will then be recorded in the database, which is read for names and scores when the gallery loads.

Is your feature request related to a problem? If so, please describe the problem: The problem is that we are trying to run a shell script from the php code. We are using the shell_exec() function to call our classifier on an image or group of images, however it is not working. We have successfully ran the classifier on our server, but we have not gotten it linked to the webpage yet. I am thinking it could be a path problem, or a stack issue.

Describe the solution you'd like: The shell_exec() function should call the classifier, and then print out the scores onto a new webpage. Once we have the scores printed out, we can then make the uploaded result webpage look like the rest of the website.

Describe alternatives you've considered: As far as getting the shell script to execute, this seems to be the only way to do it using php. However, we have considered different methods of handling the results once we get the classifier to work. Those alternatives consist of writing the scores to a database, and then pulling the scores out to display them. Or by writing the scores to a JSON file and parsing that data and displaying it after the parsing.

sgoggins commented 5 years ago

A little more description.

WestonV commented 5 years ago

I have made some good progress in terms of getting the scoring functionality to work. So, originally, our plan to get the classifier to run is to have the php function shell_exec() call a script in our directory that runs the classifier on our uploaded photos folder.

This idea seems to be a good starting point, and I do believe that we can eventually get this to work. During my first implementation attempt, I tried just throwing the following shell commands: ./predict \ --docker-image nima-cpu \ --base-model-name MobileNet \ --weights-file $(pwd)/models/MobileNet/weights_mobilenet_technical_0.11.hdf5 \ --image-source /var/www/html/uploads into a script file, and then added this to our php code where we upload the photos: $shellResponse = shell_exec("./rank.sh") echo $shellResponse
However, this did not work. I realized that I had my paths totally incorrect. After I fixed my paths I realized I forgot to give the shell script executable permissions.
So I ran the command `sudo chmod +x rank.sh"
However, after all of these fixes, I have now ran into a different problem that I have no idea how it could've been caused. Our php code isn't connecting to our DB correctly for some reason, and that is a problem. So far, this is where I am in my progress.

WestonV commented 5 years ago

As of right now, we know that this functionality works. We are still running into problems while using it, but, that is because we are overloading our server. This functionality works, and we successfully fixed issues we had that weren't allowing it to work. It is unstable however, simply because of how often it'll crash our server.

The DB problem I was experiencing earlier was actually just a symptom of the DB being turned off. Once we had gotten it turned on, the code executed as planned. After all, it was a paths and permissions problem that ended up getting fixed.