Exemplo n.º 1
0
    def run(self, args):
        result = float(0)
        for ka, kv in enumerate(args):
            if (is_number(kv) == False):
                kv = 0
            result = result + float(kv)

        return stringify(result)
Exemplo n.º 2
0
    def run(self, args):
        if len(args) > 1:
            return "#-1 TOO MANY ARGS"

        arg = args[0]
        if isinstance(arg, basestring):
            arg = float(arg)

        return stringify(fabs(arg))
Exemplo n.º 3
0
def uploadfile():
    if request.method == 'POST':
        files = request.files['file']
        print(files.filename, flush=True)
        # check validity of file
        if files and allowed_file(files.filename):
            filename = secure_filename(files.filename)
            print(filename, flush=True)
            updir = os.path.join(basedir, 'upload/')
            image_path = os.path.join(updir, filename)
            files.save(image_path)
            file_size = os.path.getsize(os.path.join(updir, filename))
        else:
            app.logger.info('ext name error')
            return jsonify(error='ext name error')
        image = decode_image(image_path)  # read in the image
        predictions = inference_instance.get_class_probabilities(image)
        return stringify(predictions)
Exemplo n.º 4
0
def radio_selection():
    if request.method == 'POST':
        selection = json.loads(request.get_data(
            as_text=True))['radio_sel']  # converts json byte string to dict
        print(selection)
        image_path = None
        if selection == '1':  #(cat)
            image_path = os.path.join(os.getcwd(), 'static', 'images',
                                      'n02121808_1421_domestic_cat.jpg')
        elif selection == '2':  # (whale)
            image_path = os.path.join(os.getcwd(), 'static', 'images',
                                      'grey_whale.jpeg')
        elif selection == '3':  # (dog)
            image_path = os.path.join(os.getcwd(), 'static', 'images',
                                      'n02084071_1365_dog.jpg')

        image = decode_image(image_path)  # read the image
        predictions = inference_instance.get_class_probabilities(image)
        return stringify(predictions)
Exemplo n.º 5
0
def test_inference():
    img_path = "grey_whale.jpeg"
    img = decode_image(img_path)
    prediction = inference_instance.get_class_probabilities(img, top_k=5)
    output = stringify(prediction)
    print(output)