#### Repository https://github.com/tensorflow/tensorflow #### What Will I Learn? Here, today we come up with a new tutorial, in this tutorial you will learn Image Recognition using Tensorflow and Kivy. Real time image recognition, open the camera to capture the image and the App automatically detect the objects from the image. - Tensorflow Image Recognition - Tensorflow with Kivy #### Requirements - Programming Fundamentals - Python Essentials - Kivy Essentials #### Difficulty - Intermediate #### Tutorial Contents - Introduction - Setting up the Environment - Develop Image Recognition ## Introduction In this tutorial we are going to develop Image Recognition App, the will allow you to detect the objects from the image. For this we'll use Tensorflow in order to detect the objects in the image, we'll talk about it in just a moment. We'll also use Kivy (a python library) to the App's GUI, if you know about our Kivy tutorial series then you know about the Kivy, but if not then please check our Kivy tutorial series. ## TensorFlow TensorFlow is an open source library and develop by researchers and engineers from the Google Brain team within Google’s AI organization for high performance numerical computation, and supports machine learning and deep learning. For more info visit [TensorFlow](https://www.tensorflow.org/). Google trained Inception-v3 for [ImageNet](http://image-net.org/) large visual recognition in which models try to classify the image into 1000 classes. For complete description please visit TensorFlow [ImageRecognition](https://www.tensorflow.org/tutorials/image_recognition). ## Setting up the Environment Before we move to develop our Image Recognition App, first we have to set a working environment that will allow us to develop our app. For this first of all [install the TensorFlow](https://www.tensorflow.org/install/) and then [install the Kivy](https://kivy.org/docs/installation) library on your machine, visit their sites in order to install. You also have to install some other python packages to run it properly on the machine, these packages are [argparse](https://pypi.org/project/argparse/) and [numpy](https://pypi.org/project/numpy/). ## Develop Image Recognition App In order to develop an Image Recognition App, first of all create a file in your text editor (we are using [PyCharm](https://www.jetbrains.com/pycharm/download/)) and save it with a name ```main.py ```. First of all we'll develop our App in Kivy, for this first import the Kivy packages, write the following code in you file. ``` import kivy kivy.require('1.9.0') from kivy.app import App from kivy.lang import Builder from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label ``` These are the packages we'll use in order to develop our app. Next up we'll develop the App's GUI, for this write the following code. ``` Builder.load_string(''' <CaputeImage>: orientation: 'vertical' Button: text: 'Capture' size_hint_y: None height: '48dp' ''') class CaputeImage(BoxLayout): pass class ImageRecognition(App): def build(self): return CaputeImage() if __name__ == "__main__": imagerecognition = ImageRecognition() imagerecognition.run() ``` Output:  Now run the camera in the app in order to capture the images, for this write this code in the ```Builder.load_string ``` method. ``` Camera: id: camera resolution: (720, 480) play: True ``` Place this code above to the capture Button code, by default we set the camera ```play:True ```, this means whenever you launch the App camera will automatically starts. Output:  You can see our camera is working fine, Now we'll capture the image using camera. For this develop a method ```def capture(self): ``` within ``` CameraClick ``` class and write the following code in order to capture the image. ``` def capture(self): ''' Function to capture the images and give them the names according to their captured time and date. ''' camera = self.ids['camera'] camera.export_to_png("test_images/IMG.png") print("Captured") self.ids['camera'].play = False ``` Also call the method whenever you click the capture button, set the this in the button properties, ``` on_press: root.capture() ``` ``` camera.export_to_png("image/IMG.png") ``` allow us to export the image into image folder and save it with name ``` IMG.png ``` . So, also make a folder with the name ``` image ``` in the working directory in order to save the images. Now run the app and click over the capture button it will capture the image and export it to ``` image ``` folder. Next up we'll move to our real work, detecting the objects from the image. For this first copy this code from [github](https://raw.githubusercontent.com/tensorflow/models/master/tutorials/image/imagenet/classify_image.py). Create a new file with name ``` imgrecog.py ``` and paste copied code in this file and save it. And import this file in the ``` main.py ``` file for this write the code. ``` import imagrecog as ir ``` Now made some changes to this code, first of all cut the main method and past it in the ``` main.py ``` file within the ``` CaputeImage ``` class. and remove the _ from the parameter body and write the self. and change the code as ``` def main(self): ir.maybe_download_and_extract() image = (ir.FLAGS.image_file if ir.FLAGS.image_file else ir.os.path.join('image/', 'IMG.png')) ir.run_inference_on_image(image) ``` Now remove the ``` if __name__ == '__main__': ``` from ``` imagerecog.py ``` and remove indentation of the code within the if statement. And lastly remove this line of cod ``` tf.app.run(main=main, argv=[sys.argv[0]] + unparsed) ``` from ``` imagerecog.py ``` file. Now move toward ``` main(self)``` method in the ``` main.py``` file. And make a label to show the returning text from the ``` imagerecog.py ``` file. For this add the following code in the method. ``` self.add_widget(Label(text=string, text_size=(600, None), line_height=1.5)) ``` Now move toward ``` capture(self) ``` method and call the main(self) method after capturing the image. Your code in the ``` capture(self) ``` method will be ``` def capture(self): ''' Function to capture the images and give them the names according to their captured time and date. ''' camera = self.ids['camera'] camera.export_to_png("test_images/IMG.png") print("Captured") self.ids['camera'].play = False self.clear_widgets() self.main() ``` At the last point open the imagerecog.py file and jump toward ``` def run_inference_on_image(image): ``` method and replace the for loop code with the following code in the method. ``` string = "" top_k = predictions.argsort()[-FLAGS.num_top_predictions:][::-1] for node_id in top_k: human_string = node_lookup.id_to_string(node_id) score = predictions[node_id] string += '%s (score = %.5f)' % (human_string, score) return string ``` Here in my file it is the line no# 162 - 168 Now run the App, you will see whatever you capture in the image the App will detect it from the image. Output:  You can see in the above image we capture the cellphone image and it detects all the possible results in the image. #### Proof of Work Done https://github.com/faad1/tensorflow-image-recognition
author | faad |
---|---|
permlink | tensorflow-image-recognition-app-in-kivy |
category | utopian-io |
json_metadata | {"tags":["utopian-io","tutorials","tensorflow","kivy"],"image":["https://cdn.steemitimages.com/DQmaKnkQAN5MpFhMiba1zCms18F2dX9u42dQi69ScnZH7yK/ImageRecognition-1.JPG","https://cdn.steemitimages.com/DQmNX5ENFbZVNLmLn9ziAM1KhryytauNSxjLqFfwrH2w4f3/ImageRecognition-2.gif","https://cdn.steemitimages.com/DQmettuJLWEF1sKVuACq8RKsDx79tdZXdku7CN1GQERiFni/ImageRecognition-3.gif"],"links":["https://github.com/tensorflow/tensorflow","https://www.tensorflow.org/","http://image-net.org/","https://www.tensorflow.org/tutorials/image_recognition","https://www.tensorflow.org/install/","https://kivy.org/docs/installation","https://pypi.org/project/argparse/","https://pypi.org/project/numpy/","https://www.jetbrains.com/pycharm/download/","https://raw.githubusercontent.com/tensorflow/models/master/tutorials/image/imagenet/classify_image.py","https://github.com/faad1/tensorflow-image-recognition"],"app":"steemit/0.1","format":"markdown"} |
created | 2018-06-12 07:06:33 |
last_update | 2018-06-12 14:10:00 |
depth | 0 |
children | 5 |
last_payout | 2018-06-19 07:06:33 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.312 HBD |
curator_payout_value | 0.037 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 7,985 |
author_reputation | 5,712,498,691,861 |
root_title | "Tensorflow: Image Recognition App in Kivy" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,408,150 |
net_rshares | 134,661,470,600 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ubg | 0 | 174,045,922 | 1% | ||
yuxi | 0 | 2,661,398,700 | 10% | ||
mercadosaway | 0 | 1,285,354,375 | 100% | ||
steemitri | 0 | 106,531,628,019 | 100% | ||
shreetbn | 0 | 7,016,045,351 | 25% | ||
r351574nc3 | 0 | 543,922,963 | 1.5% | ||
kujou | 0 | 2,027,106,186 | 100% | ||
salty-mcgriddles | 0 | 948,049,698 | 4% | ||
zcool | 0 | 164,261,042 | 10% | ||
abusereports | 0 | 0 | 2% | ||
makonsapad | 0 | 582,494,063 | 100% | ||
hakobmos | 0 | 582,494,063 | 100% | ||
sstrazzefa | 0 | 582,494,063 | 100% | ||
drsensor | 0 | 226,128,726 | 10% | ||
wagongratified | 0 | 582,494,063 | 100% | ||
banchick | 0 | 582,494,063 | 100% | ||
lanemva21 | 0 | 582,494,063 | 100% | ||
rdavis81 | 0 | 582,494,063 | 100% | ||
upperhonorable | 0 | 582,494,063 | 100% | ||
stressedboiler | 0 | 582,494,063 | 100% | ||
evasivepike | 0 | 582,494,063 | 100% | ||
roosterwage | 0 | 582,494,063 | 100% | ||
scudprocessor | 0 | 582,494,063 | 100% | ||
fadedclassic | 0 | 582,494,063 | 100% | ||
lisicka | 0 | 582,494,063 | 100% | ||
luc.real | 0 | 177,207,088 | 100% | ||
teletrasportami | 0 | 89,082,305 | 50% | ||
compasscob | 0 | 582,800,333 | 100% | ||
waveoutsiders | 0 | 582,742,083 | 100% | ||
varvenickel | 0 | 582,815,583 | 100% | ||
unlockrichard | 0 | 582,788,285 | 100% | ||
coinsicy | 0 | 582,756,799 | 100% | ||
brokenflywheel | 0 | 582,829,444 | 100% | ||
grouseunhelpful | 0 | 582,807,675 | 100% | ||
flatschowder | 0 | 582,783,141 | 100% | ||
nice-steemer | 0 | 0 | -100% | ||
zorralarousse | 0 | 0 | -100% | ||
botabuserreports | 0 | 0 | -100% | ||
tinant | 0 | 0 | -100% |
@faad you were flagged by a worthless gang of trolls, so, I gave you an upvote to counteract it! Enjoy!!
author | abusereports |
---|---|
permlink | abusereports-re-faadtensorflow-image-recognition-app-in-kivy |
category | utopian-io |
json_metadata | "" |
created | 2018-07-16 18:52:45 |
last_update | 2018-07-16 18:52:45 |
depth | 1 |
children | 0 |
last_payout | 2018-07-23 18:52:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 105 |
author_reputation | 199,407,425,243,286 |
root_title | "Tensorflow: Image Recognition App in Kivy" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 64,903,239 |
net_rshares | 0 |
Thank you for your contribution. - You have missed properly explaining in your tutorial what you are doing to the reader. Instructing readers to just copy and paste code, and add indentation does not really qualify to instruct the user or inform him how and why to do things as they are. - You have also used an incorrect github repo for tensor, [this here](https://github.com/tensorflow/tensorflow) would be a better suited one - You also referenced code that you have not used anywhere in your tutorial (about the on.press capture code). Please focus on proper explanations everywhere. ---- Need help? Write a ticket on https://support.utopian.io/. Chat with us on [Discord](https://discord.gg/uTyJkNm). [[utopian-moderator]](https://join.utopian.io/)
author | mcfarhat |
---|---|
permlink | re-faad-tensorflow-image-recognition-app-in-kivy-20180612t122941999z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"links":["https://github.com/tensorflow/tensorflow","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"} |
created | 2018-06-12 12:29:51 |
last_update | 2018-06-12 12:29:51 |
depth | 1 |
children | 1 |
last_payout | 2018-06-19 12:29:51 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 758 |
author_reputation | 150,651,671,367,256 |
root_title | "Tensorflow: Image Recognition App in Kivy" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,439,586 |
net_rshares | 0 |
Sorry for Mistake. I have updated Github Repo.
author | faad |
---|---|
permlink | re-mcfarhat-re-faad-tensorflow-image-recognition-app-in-kivy-20180612t141058111z |
category | utopian-io |
json_metadata | {"tags":["utopian-io"],"app":"steemit/0.1"} |
created | 2018-06-12 14:11:00 |
last_update | 2018-06-12 14:11:00 |
depth | 2 |
children | 0 |
last_payout | 2018-06-19 14:11:00 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 46 |
author_reputation | 5,712,498,691,861 |
root_title | "Tensorflow: Image Recognition App in Kivy" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 60,451,329 |
net_rshares | 0 |
Congratulations @faad! You received a personal award! <table><tr><td>https://steemitimages.com/70x70/http://steemitboard.com/@faad/birthday1.png</td><td>1 Year on Steemit</td></tr></table> <sub>_[Click here to view your Board of Honor](https://steemitboard.com/@faad)_</sub> > Support [SteemitBoard's project](https://steemit.com/@steemitboard)! **[Vote for its witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1)** and **get one more award**!
author | steemitboard |
---|---|
permlink | steemitboard-notify-faad-20181222t023656000z |
category | utopian-io |
json_metadata | {"image":["https://steemitboard.com/img/notify.png"]} |
created | 2018-12-22 02:36:57 |
last_update | 2018-12-22 02:36:57 |
depth | 1 |
children | 0 |
last_payout | 2018-12-29 02:36:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 490 |
author_reputation | 38,975,615,169,260 |
root_title | "Tensorflow: Image Recognition App in Kivy" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 77,201,859 |
net_rshares | 0 |
Congratulations @faad! You received a personal award! <table><tr><td>https://steemitimages.com/70x70/http://steemitboard.com/@faad/birthday2.png</td><td>Happy Birthday! - You are on the Steem blockchain for 2 years!</td></tr></table> <sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@faad) and compare to others on the [Steem Ranking](https://steemitboard.com/ranking/index.php?name=faad)_</sub> ###### [Vote for @Steemitboard as a witness](https://v2.steemconnect.com/sign/account-witness-vote?witness=steemitboard&approve=1) to get one more award and increased upvotes!
author | steemitboard |
---|---|
permlink | steemitboard-notify-faad-20191222t032918000z |
category | utopian-io |
json_metadata | {"image":["https://steemitboard.com/img/notify.png"]} |
created | 2019-12-22 03:29:18 |
last_update | 2019-12-22 03:29:18 |
depth | 1 |
children | 0 |
last_payout | 2019-12-29 03:29:18 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 604 |
author_reputation | 38,975,615,169,260 |
root_title | "Tensorflow: Image Recognition App in Kivy" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 93,625,852 |
net_rshares | 0 |