Example #1
0
 def __init__(self, CONFIG):
     try:
         self.conn = psycopg2.connect(host=CONFIG['db_host'],
                                      port=CONFIG['db_port'],
                                      database=CONFIG['db_name'],
                                      user=CONFIG['db_user'],
                                      password=CONFIG['db_password'])
     except Exception as e:
         print "Could not connect to the database"
         print e
         system.exit(2)
Example #2
0
 def exit(self, error):
     self.logout()
     system.exit(error, self.__colored)
Example #3
0
 def pong_received(data, address, udp_server):
     #print 'pong_received'
     if not (data == 'pong!' and address == ('127.0.0.1', 12345)):
         exit(1)
     reactor.stop()
Example #4
0
                                            target_size=(64, 64),
                                            batch_size=32,
                                            class_mode='binary')

classifier.fit_generator(training_set,
                         steps_per_epoch=(277 / 32),
                         epochs=25,
                         validation_data=test_set,
                         validation_steps=(73 / 32))

# Part 3 - Making new predictions

import numpy as np
from keras.preprocessing import image
test_image = image.load_img('dataset/single_prediction/pollen.jpg',
                            target_size=(64, 64))
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis=0)
result = classifier.predict(test_image)
training_set.class_indices
if result[0][0] == 1:
    prediction = 'pollen'
else:
    prediction = 'nonpollen'

print(prediction)

import system as sys

sys.exit()
Example #5
0
 def ping_received(data, address, udp_server):
     #print 'ping_received'
     if not (data == 'ping!' and address == ('127.0.0.1', 54321)):
         exit(1)
     udp_server.send_to('pong!', address)