hilalrd commited on
Commit
702f546
1 Parent(s): c9f1cdb

Upload 6 files

Browse files
Files changed (6) hide show
  1. requirements.txt +4 -0
  2. CarData.csv +5 -0
  3. SalaryData.csv +6 -0
  4. Yow.jpeg +0 -0
  5. app.py +84 -0
  6. car_model.h5 +3 -0
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ tensorflow-cpu
3
+ numpy
4
+ pandas
CarData.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ predicted_label,jenis_mobil,merek_mobil,harga_mobil_min,harga_mobil_max
2
+ 0,Alphard,Toyota,1356100000,1950000000
3
+ 1,Innova 2015-2022,Toyota,215000000,480000000
4
+ 2,Innova Zennix,Toyota,425000000,610000000
5
+ 3,New Veloz,Toyota,288000000,350000000
SalaryData.csv ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pekerjaan,rentang_usia,rentang_gaji
2
+ Staff - Fresh Graduate,"(21, 25)","(2000000, 4000000)"
3
+ Asisten Manajer,"(26, 29)","(5000000, 8000000)"
4
+ Manajer,"(29, 35)","(10000000, 15000000)"
5
+ General Manajer,"(36, 42)","(20000000, 30000000)"
6
+ Kepala Divisi atau Direksi,"(42, 100)","(50000000, 100000000)"
Yow.jpeg ADDED
app.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ from tensorflow.keras.models import load_model
3
+ import streamlit as st
4
+ from PIL import Image
5
+ import numpy as np
6
+ import pandas as pd
7
+
8
+ # Load Sequential Model
9
+ model_cnn = load_model('car_model.h5')
10
+
11
+ # Load DataFrame
12
+ df_car_info = pd.read_csv ('CarData.csv')
13
+ df_income_info = pd.read_csv ('SalaryData.csv')
14
+
15
+ def calculate_cicilan(predicted_label):
16
+ # Get car info based on predicted_label
17
+ car_info = df_car_info[df_car_info['predicted_label'] == predicted_label].iloc[0]
18
+
19
+ # Calculate cicilan_per_bulan
20
+ harga_mobil_avg = (car_info['harga_mobil_min'] + car_info['harga_mobil_max']) / 2
21
+ cicilan_per_bulan = harga_mobil_avg / 60 # 5 tahun (60 bulan)
22
+
23
+ # Find the matching gaji range based on cicilan_per_bulan
24
+ matching_income = df_income_info[
25
+ (cicilan_per_bulan / 0.3 >= df_income_info['rentang_gaji'].apply(lambda x: x[0])) &
26
+ (cicilan_per_bulan / 0.3 <= df_income_info['rentang_gaji'].apply(lambda x: x[1]))]
27
+
28
+ if not matching_income.empty:
29
+ rentang_usia = matching_income['rentang_usia'].iloc[0]
30
+ rentang_gaji_min = int(matching_income['rentang_gaji'].iloc[0][0])
31
+ rentang_gaji_max = int(matching_income['rentang_gaji'].iloc[0][1])
32
+ pekerjaan = matching_income['pekerjaan'].iloc[0]
33
+
34
+ return {
35
+ 'Jenis Mobil': car_info['jenis_mobil'],
36
+ 'Merek Mobil': car_info['merek_mobil'],
37
+ 'Rentang Usia': f"{rentang_usia[0]}-{rentang_usia[1]} Tahun",
38
+ 'Rentang Gaji': f"Rp {rentang_gaji_min} - {rentang_gaji_max}",
39
+ 'Pekerjaan': pekerjaan
40
+ }
41
+
42
+ else:
43
+ return None
44
+
45
+ def run():
46
+ st.title('Toyota Car Prediction')
47
+ st.subheader('This Prediction use for provide passanger information from his car')
48
+ st.subheader('Only Uploaded Image New Alphard, Innova 2015 - 2022, Innova Zennix, New Veloz')
49
+ st.image("Yow.jpeg")
50
+ st.markdown('---')
51
+
52
+ st.subheader('Car Prediction')
53
+ uploaded_files = st.file_uploader("Please upload an only Toyota Car image for prediction", type=["jpg"])
54
+
55
+ if uploaded_files is not None:
56
+ for fn in uploaded_files:
57
+ # Prediction with upload image
58
+ path = fn.name
59
+ img = Image.open(fn)
60
+ st.image(img, caption="Uploaded Image", use_column_width=True)
61
+ img = img.resize((224, 224))
62
+ img_array = np.array(img)
63
+ img_array = img_array / 255.0
64
+ img_array = np.expand_dims(img_array, axis=0)
65
+
66
+ # Model inference
67
+ images = np.vstack([img_array])
68
+ classes = model_cnn.predict(images)
69
+
70
+ # Memilih label kelas
71
+ predicted_label = np.argmax(classes)
72
+
73
+ # Assuming df_car_info and df_income_info are available
74
+ result = calculate_cicilan(predicted_label, df_car_info, df_income_info)
75
+
76
+ st.write("Hasil Prediksi:")
77
+ if result is not None:
78
+ for key, value in result.items():
79
+ st.write(f"{key}: {value}")
80
+ else:
81
+ st.write("Maaf, tidak ditemukan.")
82
+
83
+ if __name__ == '__main__':
84
+ run()
car_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b8e31e92f98364cc8061a351141afa0190a6a3ae83afa98b562e74d725bc24a
3
+ size 83272072