File size: 1,364 Bytes
43bf6e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56f6107
11ad137
 
43bf6e9
 
 
 
 
 
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
import time
import torch
import numpy as np
import streamlit as st

def app():
    st.write("## Fine-Tuning Model Prediction")
    st.write("### Model evaluation:")
    eval_col1, eval_col2, eval_col3, eval_col4, eval_col5 = st.columns(spec=5)
    eval_col1.metric("Precision", "99.03%")
    eval_col2.metric("Recall", "98.39%")
    eval_col3.metric("F1-Score", "98.71%")
    eval_col4.metric("mAP 0.5", "98.96%")
    eval_col5.metric("mAP 0.5:0.95", "69.61%")

    uploaded_file = st.file_uploader("Choose a ship imagery")
    if uploaded_file is not None:
        st.image(uploaded_file, caption='Image to predict')
        folder_path = st.text_input("Image path",
                                    help="This field the image path field that the model will predict the object inside the image that we have uploaded",
                                    placeholder="Copy the path of image to this field")

    prediction = st.button("Predict")
    if prediction:
        ship_model = torch.hub.load('ultralytics/yolov5', 'custom', path="apps/model/fine_tune.pt", force_reload=True)
        ship_model.conf = 0.6
        ship_model.iou = 0.55
        results = ship_model(f"{folder_path}")
        with st.spinner("Loading..."):
            time.sleep(3.5)
            st.success("Done!")
        st.image(np.squeeze(results.render()))
        results.print()