-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
34 lines (24 loc) · 802 Bytes
/
app.py
File metadata and controls
34 lines (24 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from flask import Flask, render_template, redirect, request
import Caption_it
# __name__ == __main__
app = Flask(__name__)
@app.route('/')
def hello():
return render_template("index.html")
@app.route('/', methods= ['POST'])
def marks():
if request.method == 'POST':
f = request.files['userfile']
path = "D:\Caption It\static\{}".format(f.filename)# ./static/images.jpg
f.save(path)
img_path = "{}".format(f.filename)
caption = Caption_it.caption_this_image(path)
result_dic = {
'image' : img_path,
'caption' : caption
}
return render_template("index.html", your_result =result_dic)
if __name__ == '__main__':
# app.debug = True
# due to versions of keras we need to pass another paramter threaded = Flase to this run function
app.run(debug = False, threaded = False)