bills commited on
Commit
d4942ab
1 Parent(s): ad3edf1

Added new space

Browse files
Files changed (4) hide show
  1. Procfile +1 -0
  2. apps.py +79 -0
  3. requirements.txt +11 -0
  4. runtime.txt +1 -0
Procfile ADDED
@@ -0,0 +1 @@
 
 
1
+ web: sh setup.sh && streamlit run apps.py
apps.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ from turtle import width
3
+ import torch
4
+ import folium
5
+ import numpy as np
6
+ import pandas as pd
7
+ import streamlit as st
8
+ from folium.plugins import MarkerCluster
9
+ from streamlit_folium import folium_static
10
+
11
+ st.set_page_config(
12
+ page_title="Ship Detection using YOLOv5 Medium Model",
13
+ page_icon=":ship:",
14
+ layout="wide"
15
+ )
16
+
17
+ st.write("# Welcome to Ship Detection Application! :satellite:")
18
+ st.markdown(
19
+ """
20
+ This application is build based on YOLOv5 with extral large model. User just
21
+ upload an image, and press the 'Predict' button to make a prediction base on
22
+ a training model before.
23
+
24
+ ### For more information, please visit:
25
+
26
+ - Check out [my github](https://github.com/bills1912)
27
+ - Jump into YOLOv5 [documentation](https://docs.ultralytics.com/)
28
+
29
+ """
30
+ )
31
+
32
+ st.write("## Ship Imagery Prediction")
33
+ map_col1, map_col2, map_col3 = st.columns(3)
34
+
35
+ ais = pd.read_csv("https://raw.githubusercontent.com/bills1912/marin-vessels-detection/main/data/MarineTraffic_VesselExport_2022-11-25.csv")
36
+ ais_jakarta = ais[ais['Destination Port'] == 'JAKARTA']
37
+ ais_list = ais_jakarta.values.tolist()
38
+ f = folium.Figure(width=1000, height=500)
39
+ jakarta_vessels = folium.Map(location=[-5.626954250925966, 106.70735731868719], zoom_start=8).add_to(f)
40
+ ais_data = folium.FeatureGroup(name="marine_vessels")
41
+ mCluster = MarkerCluster(name="Marine Vessels")
42
+ for i in ais_list:
43
+ html = f"<h3>{i[1]}</h3> Vessel Type: {i[8]} </br> Destination Port: {i[2]} </br> Reported Destination: {i[4]} </br> Current Port: {i[6]}\
44
+ </br> Latitude: {i[9]} </br> Longitude: {i[10]}"
45
+ iframe = folium.IFrame(html)
46
+ popup = folium.Popup(iframe, min_width=250, max_width=300)
47
+ ais_data.add_child(mCluster.add_child(folium.Marker(location=[i[10], i[11]], popup=popup, icon=folium.Icon(color="black", icon="ship", prefix="fa"))))
48
+ jakarta_vessels.add_child(ais_data)
49
+ folium_static(jakarta_vessels, width=1370, height=700)
50
+
51
+
52
+ st.write("### Model evaluation:")
53
+ eval_col1, eval_col2, eval_col3, eval_col4 = st.columns(spec=4)
54
+ eval_col1.metric("Precision", "89.52%")
55
+ eval_col2.metric("Recall", "83.54%")
56
+ eval_col3.metric("mAP 0.5", "85.39%")
57
+ eval_col4.metric("mAP 0.5:0.95", "62.63%")
58
+
59
+ uploaded_file = st.file_uploader("Choose a ship imagery")
60
+ if uploaded_file is not None:
61
+ st.image(uploaded_file, caption='Image to predict')
62
+ # st.write(uploaded_file.)
63
+
64
+ prediction = st.button("Predict")
65
+ if prediction:
66
+ ship_model = torch.hub.load('ultralytics/yolov5', 'custom', path="supercomputer/best.pt", force_reload=True)
67
+ # results = ship_model(f"C:/Users/bilva/YOLOv5/ship_test/{uploaded_file.name}")
68
+ results = ship_model(f"C:/Google Earth Pro/images/{uploaded_file.name}")
69
+ with st.spinner("Loading..."):
70
+ time.sleep(3.5)
71
+ st.success("Done!")
72
+ st.image(np.squeeze(results.render()))
73
+ results.print()
74
+ # with st.echo():
75
+ # st.text(f"results.print()")
76
+ # st.markdown(results.print())
77
+ # for percent_progress in range (100):
78
+ # time.sleep(0.1)
79
+ # progress.progress(percent_progress + 1)
requirements.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ numpy>=1.17.3
2
+ pandas==1.3.5
3
+ streamlit==1.13.0
4
+ tensorflow==2.8.0
5
+ pandas-datareader==0.10.0
6
+ sklearn==0.0
7
+ keras==2.8.0
8
+ typing-extensions>=3.10.0
9
+ streamlit-aggrid==0.3.2
10
+ tenacity==8.0.1
11
+ plotly==5.9.0
runtime.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ python-3.9.14