-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
app.py
104 lines (89 loc) · 3.93 KB
/
app.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import streamlit as st
import tensorflow.keras
from PIL import Image, ImageOps
import numpy as np
import time
from img_classifier import our_image_classifier
# import firebase_bro
# Just making sure we are not bothered by File Encoding warnings
st.set_option('deprecation.showfileUploaderEncoding', False)
def main():
# Metadata for the web app
st.set_page_config(
page_title = "Title of the webpage",
layout = "centered",
page_icon= ":shark:",
initial_sidebar_state = "collapsed",
)
menu = ['Home', 'About', 'Contact', 'Feedback']
choice = st.sidebar.selectbox("Menu", menu)
if choice == "Home":
# Let's set the title of our awesome web app
st.title('Title of your Awesome App')
# Now setting up a header text
st.subheader("By Your Cool Dev Name")
# Option to upload an image file with jpg,jpeg or png extensions
uploaded_file = st.file_uploader("Choose an image...", type=["jpg","png","jpeg"])
# When the user clicks the predict button
if st.button("Predict"):
# If the user uploads an image
if uploaded_file is not None:
# Opening our image
image = Image.open(uploaded_file)
# # Send our image to database for later analysis
# firebase_bro.send_img(image)
# Let's see what we got
st.image(image,use_column_width=True)
st.write("")
try:
with st.spinner("The magic of our AI has started...."):
label = our_image_classifier(image)
time.sleep(8)
st.success("We predict this image to be: "+label)
rating = st.slider("Do you mind rating our service?",1,10)
except:
st.error("We apologize something went wrong 🙇🏽♂️")
else:
st.error("Can you please upload an image 🙇🏽♂️")
elif choice == "Contact":
# Let's set the title of our Contact Page
st.title('Get in touch')
def display_team(name,path,affiliation="",email=""):
'''
Function to display picture,name,affiliation and name of creators
'''
team_img = Image.open(path)
st.image(team_img, width=350, use_column_width=False)
st.markdown(f"## {name}")
st.markdown(f"#### {affiliation}")
st.markdown(f"###### Email {email}")
st.write("------")
display_team("Your Awesome Name", "./assets/profile_pic.png","Your Awesome Affliation","[email protected]")
elif choice == "About":
# Let's set the title of our About page
st.title('About us')
# A function to display the company logo
def display_logo(path):
company_logo = Image.open(path)
st.image(company_logo, width=350, use_column_width=False)
# Add the necessary info
display_logo("./assets/profile_pic.png")
st.markdown('## Objective')
st.markdown("Write your company's objective here.")
st.markdown('## More about the company.')
st.markdown("Write more about your country here.")
elif choice == "Feedback":
# Let's set the feedback page complete with a form
st.title("Feel free to share your opinions :smile:")
first_name = st.text_input('First Name:')
last_name = st.text_input('Last Name:')
user_email = st.text_input('Enter Email: ')
feedback = st.text_area('Feedback')
# When User clicks the send feedback button
if st.button('Send Feedback'):
# # Let's send the data to a Database to store it
# firebase_bro.send_feedback(first_name, last_name, user_email, feedback)
# Share a Successful Completion Message
st.success("Your feedback has been shared!")
if __name__ == "__main__":
main()