Python fight

 


. Intelligent Image Recognition object . This step is the core of the intelligent magic garbage classification. Principles of artificial intelligence will come to recognize the new picture belongs classified according to label tag the massive picture. Curious readers may ask, I never learned the depth of learning ah? I will not train the model, how do?

python big laugh, "It's okay, bat and other giants have long these core capabilities of artificial intelligence packaged as an interface easy to use the! for the Double Happiness Bird rapid development, as long as we stand on the shoulders of giants on the line."

core technical principles

intelligent recognition category picture. This is Baidu smart api used, as long as the picture passed Baidu api, API will identify the picture, and the picture belongs to Category Returns an array list. Intelligent recognition of classification labels effect is shown in the picture on the left is drawing on the right is the identification and classification api Tags:

Teach you to easily develop small program python Intelligent garbage


There are such a good stuff, let's look at how to use it immediately.

First, the user application and the API key Baidu image recognition. Please venue Baidu smart api Center application.

Baidu image recognition mounting the Python  :
  • If you have installed pip, pip install baidu-aip execution can be.
  • If you have installed setuptools, you can execute python setup.py install.

Initialization AipImageClassify

AipImageClassify Python SDK is a client-side image recognition, provides a series of interactive method using image recognition developers.
AIP Import AipImageClassify from 
"" "Your AK SK APPID" ""
APP_ID = 'Your ID App'
API_KEY = 'Your Key Api'
SECRET_KEY = 'Your Key Secret'
Client = AipImageClassify (APP_ID, API_KEY, SECRET_KEY)

General object recognition interface call

the request for the general object recognition, i.e. for the input hand images shot garbage (normally decoded, and an appropriate aspect ratio), the output picture of an object and the scene tag.
"" "Read image", "" 
DEF get_file_content (filePath):
with Open (filePath, 'RB') AS FP:
return fp.read ()
Image get_file_content = ( 'example.jpg')
"" "General call object recognition "" "
client.advancedGeneral (Image);
" "" An optional argument "" "
Options = {}
Options [" baike_num "] =. 5
" "" with a parameter called generic object recognition "" "
client.advancedGeneral (Image , options)

After the call to return the results the following example:
{
"log_id": 327863200205075661,
"result_num": 5,
"result": [{
"score": 0.967622,
"root": "固体",
"baike_info": {
"baike_url": ......................

The results can be seen that the returned information contains identification information of the object tag. And has a score and other fields, actually represents what the meaning of it? Consider the following results of the detailed definition of it .

Teach you to easily develop small program python Intelligent garbage

The results detailed definition


4. Results and text similarity matching entries . Once you have the picture belongs to the category labels need to be matched according to the similarity of natural language similarity and garbage entries. After calculating matching, matching the highest return garbage micro-channel interface prompts the user what the specific classification is garbage, garbage classification since this smart little program development is completed.

Python key points involved are:

the need to structure the entry of garbage to the python code. Before design, please refer to the official garbage classification guide map.

Teach you to easily develop small program python Intelligent garbage


Python code corresponding to:
} = {trash_cat 
trash_cat [ 'Circle'] = [ 'paper', 'plastic', 'glass' .........] # recyclable
.............. ........................ # hazardous waste

The picture identification tags and garbage matching entries, select the entry that best matches the garbage.

python the key code, after the tag word is formed:
all_doc_list = []
for doc in all_doc:
doc_list = [word for word in jieba.cut(doc)]
all_doc_list.append(doc_list)

Then get word dictionary method bag (bag-of-words)
dictionary = corpora.Dictionary(all_doc_list)

Corpus made using doc2bow
corpus = [dictionary.doc2bow(doc) for doc in all_doc_list]

Similarity analysis

using TF-IDF model modeling corpus
tfidf = models.TfidfModel(corpus)

Obtaining the test document, each word of the TF-IDF value
tfidf[doc_test_vec]

Then you can according to the similarity matching, and the picture identification tag and the entry that most closely matches the classification associated, the user is returned to.

For a development program for small python programmers have to know an hour has been easier to develop an intelligent recognition can be based on Baidu smart api garbage classification program making a map of the. The magic of it!

Summary:

This article talked about the pain from the point of garbage, by way of illustration applets + micro-channel intelligent recognition api + NLP text similarity such as the development of key points, giving programmers interested in the use of artificial intelligence technology, to develop a short-term high-efficiency smart easy waste separation application pointed out a convenient road.

I hope you can python technology, make our lives easier and better. Welcomes the exchange of opinions and suggestions in the comments area.


This article represents only personal point of view, does not mean that SEO Research Association Network (www.seoxiehui.cn) official sound of views doubt please contact the author to be modified, if illegal or infringing content, please contact the publisher or author delete, For assistance, please contact platform to platform administrator mailbox [email protected]. Learn Internet marketing techniques go a giant push Institute www.jutuiedu.com.

Guess you like

Origin www.cnblogs.com/blogst/p/11411732.html