simran12m commited on
Commit
e1930e6
1 Parent(s): 1487d5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -41
app.py CHANGED
@@ -1,41 +1,32 @@
1
- from flask import Flask, render_template, jsonify, request, redirect, url_for
2
- from prediction import getAgeGender
3
-
4
- app = Flask(__name__)
5
-
6
-
7
- mediaDir = "./static/uploaded/"
8
-
9
-
10
- @app.route("/", methods = ['GET'])
11
- def index():
12
- if request.method=='GET':
13
- return render_template("index.html")
14
- else:
15
- print("Post request sent on Home Page.")
16
- return render_template("index.html")
17
-
18
-
19
- @app.route("/predict", methods = ['GET', 'POST'])
20
- def predict():
21
- if request.method=='GET':
22
- return redirect(url_for('index'))
23
- else:
24
- f = request.files['upload']
25
- if f.filename != "":
26
- image_path = mediaDir+f.filename
27
- uploaded_file_path = "uploaded/"+f.filename
28
- f.save(image_path)
29
- age, gender = getAgeGender(image_path)
30
- return render_template("prediction.html", AGE=age, GENDER=gender, FILEPATH=uploaded_file_path)
31
- else:
32
- return render_template("no_image.html")
33
-
34
-
35
- @app.errorhandler(404)
36
- def page_not_found(error):
37
- return render_template('404.html'), 404
38
-
39
-
40
- if __name__ == '__main__':
41
- app.run(host="0.0.0.0", port=80, use_reloader=True, debug=True)
 
1
+ import streamlit as st
2
+ from streamlit_option_menu import option_menu
3
+ import prediction
4
+ import home
5
+ import contact
6
+
7
+
8
+ st.write('### Age and Gender Prediction')
9
+ st.write('##### This page is created by [Simran Bola]')
10
+ st.markdown('---')
11
+
12
+
13
+ selected = option_menu(None, ["Home", "Predict","Contact"],
14
+ icons=['house', 'gear-fill', 'envelope-at-fill'],
15
+ menu_icon="cast", default_index=0, orientation="vertical",
16
+ styles={
17
+ "icon": {"color": "yellow", "font-size": "20px"},
18
+ "nav-link": {"font-size": "20px", "text-align": "left", "margin":"1px", "--hover-color": "#eee"},
19
+ "nav-link-selected": {"background-color": "grey"},
20
+ }
21
+ )
22
+
23
+ selected
24
+
25
+
26
+ if selected == 'Predict':
27
+ prediction.run()
28
+
29
+ elif selected == 'Home':
30
+ home.run()
31
+ else:
32
+ contact.run()