Exemplo n.º 1
0
if __name__ == '__main__':
    url = ''
    t = Tensor(url)
    imgs = []
    i = 0
    #folder="home/turtle/Desktop"
while (1):

    imgs.append(os.path.join("/home/turtle/images/image" + str(i) + ".jpg"))

    #      sleep(1)

    image = "/home/turtle/images" + '/' + imgs[i]
    #end=time.time()

    res = t.classify(imgs[i])
    #print(end-start)

    resp = json.dumps(res)
    #rep=repr(res)
    #print (rep)
    #f resp.endswith('}'):
    #os.remove(image)
    # print('hi')
    fromaddr = ""
    toaddr = ""
    msg = MIMEMultipart()
    msg['From'] = "tensor"
    msg['To'] = "flow"
    msg['Subject'] = "TENSORFLOW CLASSIFICATION RESULT"
    body = "\n" + res
Exemplo n.º 2
0
from email.mime.multipart import MIMEMultipart
import os
import smtplib
import random

if __name__ == '__main__':
    url = ''
    t = Tensor(url)
    folder = "/home/mahima/images"
while (true):
    for filename in os.listdir("/home/mahima/images"):
        numberoffiles = len(folder)
        img = random.choice(os.listdir("/home/mahima/images"))
        image = folder + '/' + img
        print(numberoffiles)
        res = t.classify(image)
        os.remove(image)
        #sending response as an email
        fromaddr = ""
        toaddr = ""
        msg = MIMEMultipart()
        msg['From'] = "Tensorflow"
        msg['To'] = "Mahima"
        msg['Subject'] = "TENSORFLOW CLASSIFICATION RESULT"
        body = '/n' + res
        msg.attach(MIMEText(body, 'plain'))
        filename = image
        attachment = open(image, "rb")
        part = MIMEBase('application', 'octet-stream')
        part.set_payload((attachment).read())
        encoders.encode_base64(part)