Shri
Shri

Reputation: 51

Tensorflow bulk image classification

I have few questions about TensorFlow. I'm following the "TensorFlow for Poets" tutorial (https://petewarden.com/2016/02/28/tensorflow-for-poets/), and i got the expected result. However i would like to know two thing: 1. How to classify more than one image at a time? 2. How to extract the result in .txt format?

Thank you

Upvotes: 1

Views: 1144

Answers (2)

ThomasDr
ThomasDr

Reputation: 356

I am currently using the "find" command.

find ./ -type f -iname "*.jpg" -exec python3 classify_image.py --image={} \;

But I'm also looking for a solution that does not have to load the complete script for every image.

Upvotes: 0

Michael Mintz
Michael Mintz

Reputation: 15461

I had the same issue, so I built the TensorPy GitHub repo to easily handle image classifications of either individual or multiple images directly from web pages. How it works: For multiple images, first it scrapes all the image links directly from a web page given. Then it downloads those images to a temporary folder and converts those images to JPEG format. Finally, it uses TensorFlow to classify all those images and print out the result, which you can then easily output to a txt file by adding " > output.txt" to the end of your command line run statement. See the video tutorial link in the repo, and swap out the individual image file from the example for a web page. Since you probably want your own customization, feel free to look at how the code works so that you can create your own version as you need it.

After creating my solution, I saw that there are also other good solutions available online. Check out Siraj's image classification tutorial, which has a link to the associated GitHub repo in the video description.

UPDATE: If you're just looking to run TensorFlow's classify_image.py on multiple image files in a folder, you can easily create a bash script for that:

   for i in temp_image_folder/*.jpg; do
   python classify_image.py --image=$i
   done

Upvotes: 2

Related Questions