File size: 2,356 Bytes
a6dc334
 
 
 
 
 
 
5f207f8
eafce8c
 
8a7713f
a6dc334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pickle
import streamlit as st
import pickle
import streamlit as st
import tensorflow as tf
import numpy as np
from PIL import Image
import joblib
# with open("Trained_model.sav","rb") as a:
#    loaded_model=pickle.load(a)
loaded_model=joblib.load("Trained_model.sav")
def app():
                  
                  
                   def pred_and_plot(model, filename):
                       
                     # Make a prediction
                       pred = model.predict(filename)
                       return pred
                    
                  
                   st.markdown('''<p style="font-family:sans-serif; color:white; font-size: 42px"> <b>**Get cyclone intensity with the click of a button.**</b></p>''',unsafe_allow_html=True)
                                     
                   
                   st.markdown('''<p style="font-family:sans-serif; color:white; font-size: 20px;">Sample image πŸ‘‡</p>''',unsafe_allow_html=True)
                   sample_img="30.jpg"
                   
                   
                   st.image(
                          sample_img,
                          caption=f"This is a sample image which you feed in this app and calculate the intensity :)",
                          use_column_width=True,
                      )
                   st.markdown('''<p style="font-family:sans-serif; color:white; font-size: 20px;">Upload an image πŸ‘‡</p>''',unsafe_allow_html=True)
                   file = st.file_uploader("Image",type=["png", "jpg", "jpeg"])
                  
                   if file is not None:
                      image = Image.open(file)
                  
                      st.image(
                          image,
                          caption=f"You amazing image has shape",
                          use_column_width=True,
                      )
                      img_array = np.array(image)
                      img = tf.image.resize(img_array, size=(256,256))
                      img = tf.expand_dims(img, axis=0)
                      img=img/255.
                      if st.button('Compute Intensity'):
                        intensity=pred_and_plot(loaded_model,img)
                        st.markdown("The intensity of your image in KNOTS is πŸ‘‡")
                        st.success(intensity)