Пример #1
0
def predict():
    print(request.args)
    if (request.args):
        x_input, predictions = make_prediction(request.args['chat_in'])
        print(x_input)
        return flask.render_template('predictor.html',
                                     chat_in=x_input,
                                     prediction=predictions)
    else:
        x_input, predictions = make_prediction('')
        return flask.render_template('predictor.html',
                                     chat_in=x_input,
                                     prediction=predictions)
Пример #2
0
def process():
    if request.method == 'POST':
        #choice = request.form['taskoption']
        rawtext = request.form['rawtext']
        doc = nlp(rawtext)
        subjectivity = make_prediction(rawtext)
        if subjectivity[1][-1]['prob'] > 0.6:
            subjectivity[1][-1]['prob'] = 'POSITIVE'
        if subjectivity[1][-1]['prob'] < 0.6 and subjectivity[1][-1][
                'prob'] > 0.35:
            subjectivity[1][-1]['prob'] = 'NEUTRAL'
        else:
            subjectivity[1][-1]['prob'] = 'NEGATIVE'

        res = []
        subj = []
        for item in subjectivity[1]:
            if item['name'] == 'sentiment':
                subj.append({item['name']: item['prob']})
            else:
                subj.append(
                    {item['name']: str(round(item['prob'] * 10000, 2)) + '%'})
        d = []
        for ent in doc.ents:
            d.append({"Text": ent.text, "Entity": ent.label_})

    return render_template("index.html",
                           text=subjectivity[0],
                           subjectivity=subj,
                           entities=d,
                           num_of_results=len(d))
Пример #3
0
def predict():
    photoFile = request.files['file']
    result, result_val = make_prediction(photoFile)
    return {
        "result": result,
        "result_val": result_val
    }
Пример #4
0
def predict():
    # request.args contains all the arguments passed by our form
    # comes built in with flask. It is a dictionary of the form
    # "form name (as set in template)" (key): "string in the textbox" (value)
    print(request.args)
    if request.args:
        x_input, prediction = make_prediction(request.args['input'])
        return flask.render_template('bootstrap.html',
                                     x_input=x_input,
                                     prediction=prediction,
                                     show_predictions_modal=True)
    else:
        x_input, prediction = make_prediction('')
        return flask.render_template('bootstrap.html',
                                     x_input=x_input,
                                     prediction=prediction,
                                     show_predictions_modal=True)
Пример #5
0
def predict():
    m = make_prediction("garbage.jpeg")
    print(m)
    if (m == 1):
        return '''
        true '''

    return ''' false '''
Пример #6
0
def predict():
    # request.args contains all the arguments passed by our form
    # comes built in with flask. It is a dictionary of the form
    # "form name (as set in template)" (key): "string in the textbox" (value)
    x_input, predictions = make_prediction(request.args)
    return flask.render_template('predictor.html', x_input=x_input,
                                 feature_names=feature_names,
                                 prediction=predictions)
def predict():
    # request.args contains all the arguments passed by our form
    # comes built in with flask. It is a dictionary of the form
    # "form name (as set in template)" (key): "string in the textbox" (value)
    print(request.args)
    if (request.args):
        x_input, predictions = make_prediction(request.args['chat_in'])
        print(x_input)
        return flask.render_template('predictor.html',
                                     chat_in=x_input,
                                     prediction=predictions)
    else:
        #For first load, request.args will be an empty ImmutableDict type. If this is the case,
        # we need to pass an empty string into make_prediction function so no errors are thrown.
        x_input, predictions = make_prediction('')
        return flask.render_template('predictor.html',
                                     chat_in=x_input,
                                     prediction=predictions)
Пример #8
0
def print_piped():
    if request.form['mes']:
        msg = request.form['mes']
        print(msg)
        x_input, predictions = make_prediction(str(msg))
        flask.render_template('predictor.html',
                              chat_in=x_input,
                              prediction=predictions)
    return jsonify(predictions)
def api_predict():
    # request.args contains all the arguments passed by our form
    # comes built in with flask. It is a dictionary of the form
    # "form name (as set in template)" (key): "string in the textbox" (value)
    print(request.args)
    if (request.args):
        x_input, predictions = make_prediction(request.args['input'])
        print(x_input)
        a = {}
        print("PREDICTIONS" + str(predictions))
        for pred in predictions:
            a[pred['name']] = pred['prob']
        return a
    else:
        #For first load, request.args will be an empty ImmutableDict type. If this is the case,
        # we need to pass an empty string into make_prediction function so no errors are thrown.
        x_input, predictions = make_prediction('')
        for pred in predictions:
            a[pred['name']] = pred['prob']
        return a
Пример #10
0
def collaborative():
    # request.args contains all the arguments passed by our form
    # comes built in with flask. It is a dictionary of the form
    # "form name (as set in template)" (key): "string in the textbox" (value)
    # if request.method == "POST":

    prediction = None
    if request.method == 'POST':
        favorite_movie = request.form['favorite_movie']
        prediction = make_prediction(favorite_movie)

    # show the form, it wasn't submitted
    return render_template('collaborative.html', prediction=prediction)
Пример #11
0
def predict():
    if request.method == 'POST':
        data = json.loads(request.data)
        url = data[0]["payload"]["url"]
        image = requests.get(url)
        img = Image.open(BytesIO(image.content))
        print(type(img))
        print(type(image))
        print(url)
        print(image)
        print(img)
        result = predictor_api.make_prediction(url)
    return jsonify({'result': result})
Пример #12
0
def predict():

    class_info = get_class_info(request.form)
    yoga_class = get_class(request.form)

    x_input, predictions = make_prediction(class_info)
    if request.method == 'POST':
        result = yoga_class
        result2 = class_info
        return flask.render_template("results.html",
                                     result=result,
                                     result2=result2,
                                     prediction=predictions,
                                     x_input=x_input)
Пример #13
0
def predict():

    # x_input, prediction = make_prediction(request.args.to_dict())

    # return flask.render_template('predictor.html',
    #                              x_input = x_input,
    #                              cols = cols,
    #                              prediction = prediction)

    df, prediction = make_prediction(request.args.to_dict())
    # df = df[cols]
    return flask.render_template('predictor.html',
                                 columns=cols,
                                 df=df,
                                 prediction=prediction)
Пример #14
0
def show_image():
    if request.method == "POST":
        if 'file' not in request.files:
            return redirect('/')
        file = request.files['file']
        if file.filename == '':
            flash('No selected file')
            return redirect(request.url)
        if file and allowed_file(file.filename):
            filename = secure_filename(file.filename)
            file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
            input = os.path.join(app.config['UPLOAD_FOLDER'], filename)
            input_image, prediction = make_prediction(input_image=input)
            return flask.render_template('predictor.html',
                                         uploaded_photo=input_image,
                                         prediction=prediction)
    return flask.render_template('predictor.html',
                                 uploaded_photo='',
                                 prediction='')
Пример #15
0
def predict():
    blueWardsPlaced = request.args.get('blueWardsPlaced')
    blueWardsDestroyed = request.args.get('blueWardsDestroyed')
    blueFirstBlood = request.args.get('blueFirstBlood')
    blueDragons = request.args.get('blueDragons')
    blueHeralds = request.args.get('blueHeralds')
    blueTowersDestroyed = request.args.get('blueTowersDestroyed')
    blueGoldDiff = request.args.get('blueGoldDiff')
    blueExperienceDiff = request.args.get('blueExperienceDiff')
    redWardsPlaced = request.args.get('redWardsPlaced')
    redWardsDestroyed = request.args.get('redWardsDestroyed')
    redDragons = request.args.get('redDragons')
    redHeralds = request.args.get('redHeralds')
    redTowersDestroyed = request.args.get('redTowersDestroyed')
    return render_template(
        'index.html',
        prediction=make_prediction(blueWardsPlaced, blueWardsDestroyed,
                                   blueFirstBlood, blueDragons, blueHeralds,
                                   blueTowersDestroyed, blueGoldDiff,
                                   blueExperienceDiff, redWardsPlaced,
                                   redWardsDestroyed, redDragons, redHeralds,
                                   redTowersDestroyed))
Пример #16
0
def predict(choice):
	f = None
	caption= None
	summary = None
	if request.method == 'POST':

		if choice==1 or choice==2: # new story on image upload
			f = request.files['image-input']
			upload_image(f)
			caption = make_prediction()
			#if choice ==1:
			if request.form['image_button'] == 'new-image':
				summary=new_story_with_caption(caption)
				print(summary)
			else:
				summary=continue_story_with_caption(caption)
				print(summary)
		elif choice ==3: # continue story without image
			caption=" "
			summary=continue_story_without_caption()
		elif choice ==4: # continue story with user text
			caption = request.form['inputtext']
			summary=continue_story_with_text(caption)
	return render_template('index.html', image=f, result=caption,summary=summary)
Пример #17
0
def uploaded_file(filename):
    image = filename
    msg = make_prediction(image)
    return render_template('result.html', msg=msg, image=image)
Пример #18
0
def predict():
    x_input, predictions = make_prediction(request.args)
    return flask.render_template('predictor.html',
                                 x_input=x_input,
                                 feature_names=feature_names,
                                 prediction=predictions)