Ejemplo n.º 1
0
def predict():
    img = request.files['image']
    path = "./static/{}".format(img.filename)
    img.save(path)
    caption = caption_it.caption_this_image(path)
    print(caption)

    example_sent = caption
    stop_words = set(stopwords.words('english'))

    word_tokens = word_tokenize(example_sent)

    filtered_sentence = [w for w in word_tokens if not w in stop_words]

    filtered_sentence = []

    for w in word_tokens:
        if w not in stop_words:
            filtered_sentence.append(w)

    print(word_tokens)
    print(filtered_sentence)
    os.remove(path)

    return jsonify(msg=caption, tags=filtered_sentence)
Ejemplo n.º 2
0
def marks():
    if request.method == 'POST':
        f = request.files['userfile']
        path = "./static/{}".format(f.filename)
        f.save(path)
        caption = caption_it.caption_this_image(path)
        caption1 = "in the entered image      " + caption
        text_to_speech(caption1)
        diction = {'image': path, 'caption': caption}
    return render_template('index.html', your_result=diction)
Ejemplo n.º 3
0
def cap():
    if request.method == 'POST':
        f = request.files['userfile']
        path = "./static/{}".format(f.filename)
        f.save(path)

    caption = caption_it.caption_this_image(path)
    result_dic = {'image': path, 'caption': caption}

    return render_template("index.html", your_result=result_dic)