AhmadHashim commited on
Commit
0d2daf9
·
verified ·
1 Parent(s): 66e7db8

Sync local Space with Hub

Browse files
Files changed (1) hide show
  1. app.py +62 -0
app.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests as req
3
+ from streamlit_lottie import st_lottie
4
+ from prediction_helper import predict_class_way1, predict_class_way2
5
+
6
+ st.set_page_config(page_title="Welcome to Iris Classifier",page_icon=":blossom:")
7
+
8
+ with st.container():
9
+ st.title("Welcome to Iris Classifier :blossom:")
10
+ st.subheader("Author: Ahmad Baseer")
11
+ st.write("You can find the code [here](https://github.com/Ahmad-Baseer/AI-Projects)")
12
+
13
+ st.write("---")
14
+
15
+ def load_lottieurl(url):
16
+ r=req.get(url)
17
+ if r.status_code !=200:
18
+ None
19
+ return r.json()
20
+
21
+ lottie_flower=load_lottieurl("https://lottie.host/db599348-de9d-44a3-9e66-6490a4920520/jiH4zhQwAD.json")
22
+
23
+ left_col, right_col = st.columns(2)
24
+
25
+ with left_col:
26
+ # Create four input fields.
27
+ sepal_length = st.number_input("Sepal length (cm)", min_value=0.0, max_value=100.0)
28
+ sepal_width = st.number_input("Sepal width (cm)", min_value=0.0, max_value=100.0)
29
+ petal_length = st.number_input("Petal length (cm)", min_value=0.0, max_value=100.0)
30
+ petal_width = st.number_input("Petal width (cm)", min_value=0.0, max_value=100.0)
31
+
32
+ datapoint = [sepal_length,sepal_width,petal_length,petal_width]
33
+
34
+ # Display the input fields.
35
+ st.write("Sepal length:", sepal_length)
36
+ st.write("Sepal width:", sepal_width)
37
+ st.write("Petal length:", petal_length)
38
+ st.write("Petal width:", petal_width)
39
+ st.write(" **This model got accuracy of:** ", 0.8933)
40
+
41
+ if(sepal_length!=0 and sepal_width!=0 and petal_length!=0 and petal_width!=0):
42
+ st.write("---")
43
+ result_1=predict_class_way1(datapoint)
44
+ result_2=predict_class_way2(datapoint)
45
+
46
+ st.write(f" I guess 🤔 it belongs to (using method 1): **{result_1.capitalize()}** ")
47
+ st.write(f" I guess 🤔 it belongs to (using method 2): **{result_2.capitalize()}** ")
48
+
49
+ if result_1==result_2:
50
+ st.write(" **Hurray :partying_face: we got same results from both techniques!**")
51
+
52
+ with right_col:
53
+ st_lottie(lottie_flower,height=250,key="flower")
54
+
55
+ st.caption("Made with :heart: by Ahmad")
56
+
57
+ #using local css to design contact form
58
+ def local_css_for_contact_form(file_name):
59
+ with open(file_name) as f:
60
+ st.markdown(f"<style>{f.read()}</style>",unsafe_allow_html=True)
61
+
62
+ local_css_for_contact_form("style.css")