File size: 2,466 Bytes
07ced8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Import Library
import numpy as np
import streamlit as st
import tensorflow as tf
import tensorflow.keras as keras
import os
from PIL import Image

# Import the created Prediction Model
from prediction import image_preprocessing, AnimalClassifier
from eda import visual_path

dataset_path = "Felidae/"
train_path = "train/"
test_path = "test/"
val_path = "validation/"

model = keras.models.load_model('model.h5')

# Streamlit web app
def main():
    st.markdown("<h1 style='text-align: center;'>Cat Species Recognition App</h1>", unsafe_allow_html=True)
    st.image("https://st2.depositphotos.com/1008660/9611/i/950/depositphotos_96115196-stock-photo-five-big-wild-cats.jpg")
    st.caption("<p style='text-align: center;'>Source : Depositphotos.com</p>", unsafe_allow_html=True)
    st.write('**Author      : Salsa Sabitha Hurriyah**')
    st.write('**Computer Vision Model for Cat Species Recognition**')
    st.write('---')
    uploaded_file = st.file_uploader("Choose a file",type=(['png','jpg','jpeg']))
    
    if uploaded_file is not None:
        
        st.subheader("Uploaded File")
        st.image(uploaded_file)
        uploaded_file = Image.open(uploaded_file)
        image = image_preprocessing(uploaded_file)
        classifier = AnimalClassifier()
        words = classifier.model_pred(model,image)
        
        # See prediction
        st.write(f'# Model See this Cat Species as "{words}"')

    # Tambahkan tombol untuk melakukan visualisasi EDA
    if st.button('Explore Dataset'):
        # Visualisasi dataset
        if os.path.exists(dataset_path):
            st.subheader('Dataset Path Visualization')
            visual_path(dataset_path)
        else:
            st.error('Dataset path does not exist!')

        # Visualisasi data latih
        if os.path.exists(train_path):
            st.subheader('Train Path Visualization')
            visual_path(train_path)
        else:
            st.error('Train path does not exist!')

        # Visualisasi data uji
        if os.path.exists(test_path):
            st.subheader('Test Path Visualization')
            visual_path(test_path)
        else:
            st.error('Test path does not exist!')

        # Visualisasi data validasi
        if os.path.exists(val_path):
            st.subheader('Validation Path Visualization')
            visual_path(val_path)
        else:
            st.error('Validation path does not exist!')

if __name__ == "__main__":
    main()