File size: 1,852 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
import os
import streamlit as st
import matplotlib.pyplot as plt

# Function untuk menampilkan visualisasi jumlah data untuk setiap class
def visual_path(path):
    labels = os.listdir(path)
    label_names = []
    num_data = []
    for label in labels:
        # Skip jika nama direktori dimulai dengan .DS_Store
        if label.startswith('.DS_Store'):
            continue
        label_names.append(label)
        num_data.append(len(os.listdir(os.path.join(path, label))))

    # Membuat plot bar
    plt.figure(figsize=(10, 6))
    plt.bar(label_names, num_data, color='skyblue')
    plt.xlabel('Label')
    plt.ylabel('Number of Data')
    plt.title(f'Number of Data for Each Label in {os.path.basename(path)} Set')
    plt.xticks(rotation=45)
    plt.tight_layout()
    st.pyplot(plt)

# Main Streamlit app
def main():
    st.title('Dataset Visualization')

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

    # Visualize each path
    if st.button('Visualize'):
        if os.path.exists(dataset_path):
            st.subheader('Dataset Path Visualization')
            visual_path(dataset_path)
        else:
            st.error('Dataset path does not exist!')

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

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

        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()