Skip to main content

Posts

Showing posts from August, 2020

Image Identify using machine learning in Python.

#pip install imageai #pip install Tensorflow #pip install keras from  imageai.Prediction  import  ImagePrediction import  os from  keras.models  import  load_model Givenimage= "picc.jpg" execution_path=os.getcwd() #print(execution_path) prediction = ImagePrediction() prediction.setModelTypeAsSqueezeNet() prediction.setModelPath(os.path.join(execution_path,  "squeezenet_weights_tf_dim_ordering_tf_kernels.h5" )) prediction.loadModel() predictions, probabilities = prediction.predictImage(os.path.join(execution_path, Givenimage), result_count= 3  ) for  eachPrediction, eachProbability  in   zip (predictions, probabilities):      print (eachPrediction ,  " : "  , eachProbability)   Result: WARNING:tensorflow:11 out of the last 11 calls to <function Model.make_predict_function.<locals>.predict_function at 0x7f941e211598> tr...

Read The Hacker News in efficient way using Python Programming.

import  requests from  bs4  import  BeautifulSoup  import  pprint url= 'https://news.ycombinator.com/' url2= 'https://news.ycombinator.com/news?p=2' res=requests.get(url) res2=requests.get(url2) soup=BeautifulSoup(res.text, 'html.parser' ) soup2=BeautifulSoup(res2.text, 'html.parser' ) links=soup.select( '.storylink' ) subtext=soup.select( '.subtext' ) links2=soup2.select( '.storylink' ) subtext2=soup2.select( '.subtext' ) def   sorting_votes ( hnlist ):    return   sorted (hnlist,key= lambda  k:k[ 'votes' ],reverse= True ) megalinks=links + links2 megasubtext=subtext+subtext2 def   custom_hn ( links , subtext ):   hn=[]    for  idx,item  in   enumerate (links):     title=links[idx].getText()     href=links[idx].get( 'href' , None )     vote=subtext[idx].select( '.score' )           if...