def fiscTrain(csv_file, model_filename): print "Fischer training" print csv_file print model_filename global model model = recognition.get_model_from_csv(filename=csv_file, out_model_filename=model_filename) print model
def identifyAndTrain(image_path, csv_file, model_filename): print "With Training" print image_path print csv_file print model_filename global model model = recognition.get_model_from_csv(filename=csv_file, out_model_filename=model_filename) print model image = open(image_path, 'rb') #open binary file in read mode image_read = image.read() image_data = base64.encodestring(image_read) #print image_data prediction = get_prediction(image_data) return prediction
"--port", action="store", dest="port", default=5000, help="Sets the port for this server.", required=False) parser.add_argument('model_filename', nargs='?', help="Filename of the model to use or store") # Print Usage: print "=== Usage ===" parser.print_help() # Parse the Arguments: args = parser.parse_args() # Uh, this is ugly... global model # If a DataSet is given, we want to work with it: if args.dataset: # Learn the new model with the dataset given: model = recognition.get_model_from_csv( filename=args.dataset, out_model_filename=args.model_filename) else: model = recognition.load_model_file(args.model_filename) # Finally start the server: print "=== Server Log (also in %s) ===" % (LOG_FILENAME) app.run(host=args.host, port=args.port, debug=True, use_reloader=False, threaded=False)
print "=== Description ===" print long_description print "=== Usage ===" print "Usage:", usage print "=== Server Log (also in %s) ===" % (LOG_FILENAME) # Parse the command line: from optparse import OptionParser parser = OptionParser(usage=usage) parser.add_option("-t", "--train", action="store", type="string", dest="dataset", default=None, help="Calculates a new model from a given CSV file. CSV format: <person>;</path/to/image/folder>.") # Split between options and arguments (options, args) = parser.parse_args() # Check if a model filename was passed: if len(args) == 0: print "Expected a facerec model to use for recognition!" sys.exit() # The filename of the model: model_filename = args[0] # Uh, this is ugly... global model # If a DataSet is given, we want to work with it: if options.dataset: # Learn the new model with the dataset given: model = recognition.get_model_from_csv(filename=options.dataset,out_model_filename=model_filename) else: model = recognition.load_model_file(model_filename) # Finally start the server: app.run(host="0.0.0.0", port=int("5000"), debug=True, use_reloader=False, threaded=False)
) parser.add_argument( "-a", "--address", action="store", dest="host", default="0.0.0.0", help="Sets the endpoint for this server.", required=False, ) parser.add_argument( "-p", "--port", action="store", dest="port", default=5000, help="Sets the port for this server.", required=False ) parser.add_argument("model_filename", nargs="?", help="Filename of the model to use or store") # Print Usage: print "=== Usage ===" parser.print_help() # Parse the Arguments: args = parser.parse_args() # Uh, this is ugly... global model # If a DataSet is given, we want to work with it: if args.dataset: # Learn the new model with the dataset given: model = recognition.get_model_from_csv(filename=args.dataset, out_model_filename=args.model_filename) else: model = recognition.load_model_file(args.model_filename) # Finally start the server: print "=== Server Log (also in %s) ===" % (LOG_FILENAME) app.run(host=args.host, port=args.port, debug=True, use_reloader=False, threaded=False)