Spaces:
Sleeping
Sleeping
# 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() | |