jableable commited on
Commit
548a54a
1 Parent(s): 4cb3cd0

Upload 2 files

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. 0.0008-0.92.keras +3 -0
  3. streamlit_app.py +79 -0
.gitattributes CHANGED
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  best_model.keras filter=lfs diff=lfs merge=lfs -text
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  best_model.keras filter=lfs diff=lfs merge=lfs -text
37
+ 0.0008-0.92.keras filter=lfs diff=lfs merge=lfs -text
0.0008-0.92.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6e3e3765a66ab2d69de87338880087525386c6146138422fc0dcd27405ffcb00
3
+ size 2335883425
streamlit_app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import keras
3
+ import numpy as np
4
+ from PIL import Image
5
+
6
+ st.set_page_config(layout="wide")
7
+
8
+ #title
9
+ st.title('Crossing Identifier')
10
+
11
+ #header
12
+ st.header('Choose whether you\'d like to enter a latitude/longitude coordinates, or upload a satellite image.')
13
+
14
+
15
+
16
+ state = st.session_state
17
+
18
+ if "dict_options" not in state:
19
+ state.dict_options = {}
20
+
21
+ if "submitted" not in state:
22
+ state.submitted = False
23
+
24
+ options = ["option1", "option2", "option3", "option4"]
25
+
26
+ col1, col2, col3 = st.columns(3)
27
+
28
+ with col1.form("my_form"):
29
+ new_country = st.text_input("New country")
30
+ submit_button = st.form_submit_button(
31
+ label="Add new country", on_click=lambda: state.update(submitted=True)
32
+ )
33
+
34
+ if state.submitted:
35
+ state.dict_options[new_country] = col2.multiselect(
36
+ f"Select the options you want for {new_country}",
37
+ options,
38
+ default=options[:2],
39
+ )
40
+ col2.write(state.dict_options)
41
+
42
+
43
+
44
+ #divide app into two columns
45
+ col1, col2 = st.columns(2)
46
+
47
+ #load model and initialize image size required by model. uploaded images are resized to indicated size
48
+ loaded_model = keras.models.load_model("0.0008-0.92.keras")
49
+ img_height = 640
50
+ img_width = 640
51
+
52
+ #place to enter
53
+
54
+ #place to enter coordinates (or upload) and display image
55
+ with col1:
56
+ enter_coords = st.button("Enter Coordinates")
57
+ if enter_coords:
58
+ st.write(":smile:")
59
+ upload_img = st.button("Upload an Image")
60
+ if enter_coords:
61
+ st.write("ok")
62
+
63
+ st.header('Please upload a satellite image, or enter a latitude/longitude pair')
64
+ img_buffer = st.file_uploader("Upload a satellite image file (format: .png, .jpeg, or .jpg).",type=['png', 'jpeg', 'jpg'])
65
+ if img_buffer is not None:
66
+ st.image(img_buffer, use_column_width = True)
67
+
68
+ #place to display prediction result
69
+ with col2:
70
+ if img_buffer is not None:
71
+ st.header('Result')
72
+ img = Image.open(img_buffer).convert("RGB")
73
+ img_array = np.array(img)
74
+ batch_size = 1
75
+ img_array = np.reshape(img_array,[batch_size,img_height,img_width,3])
76
+ result = loaded_model.predict(img_array)
77
+ st.write("Your prediction is:")
78
+ st.write(f"{np.round(result[0][0]*100,decimals=2)}% chance of no crossing")
79
+ st.write(f"{np.round(result[0][1]*100,decimals=2)}% chance of at least one crossing")