Abdul-Haseeb commited on
Commit
f53f171
·
verified ·
1 Parent(s): 12299a6

Upload 2 files

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. app.py +53 -0
  3. vehicle_recognition_model.keras +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ vehicle_recognition_model.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ from PIL import Image
5
+ import matplotlib.pyplot as plt
6
+ import tensorflow as tf
7
+ from tensorflow import keras
8
+ from tensorflow.keras.models import load_model
9
+ from tensorflow.keras.preprocessing import image
10
+ from tensorflow.keras.applications.efficientnet import preprocess_input
11
+
12
+ def predict(uploaded_file, model, classes):
13
+ img = Image.open(uploaded_file)
14
+ img = img.resize((300, 300))
15
+ img_array = np.array(img)
16
+ img_array = np.expand_dims(img_array, axis=0)
17
+ img_array = preprocess_input(img_array)
18
+
19
+ prediction = model.predict(img_array)
20
+ predicted_class_index = np.argmax(prediction)
21
+ predicted_class_label = classes[predicted_class_index]
22
+
23
+ st.write(f"Predicted Vehicle: {predicted_class_label}")
24
+ st.image(img, use_column_width=True)
25
+
26
+ def run():
27
+ st.header('Vehicle Type Recognition :busstop:')
28
+ st.write('The objective of this project is to build a machine learning model to classify vehicles into the following categories using Convolutional Neural Networks.')
29
+ st.markdown("""
30
+ - Auto Rickshaw :auto_rickshaw:
31
+ - Bicycle :bicyclist:
32
+ - Bus :bus:
33
+ - Car :car:
34
+ - Motorcycle :racing_motorcycle:
35
+ - Truck :truck:
36
+ - Van :minibus:
37
+ """)
38
+
39
+ with st.form(key='Form Upload Vehicle Type Recognition'):
40
+ uploaded_files = st.file_uploader("Choose a .JPEG/.JPG/.PNG file", accept_multiple_files=True)
41
+
42
+ if uploaded_files:
43
+ for uploaded_file in uploaded_files:
44
+
45
+ st.write("filename:", uploaded_file.name)
46
+ model = load_model('vehicle_recognition_model.keras')
47
+ classes = ['Auto-rickshaw :auto_rickshaw:', 'Bicycle :bicyclist:', 'Bus :bus:', 'Car :car:', 'Motorcycle :racing_motorcycle:', 'Truck :truck:', 'Van :minibus:']
48
+ predict(uploaded_file, model, classes)
49
+
50
+ st.form_submit_button(label='Submit')
51
+
52
+ if __name__ == '__main__':
53
+ run()
vehicle_recognition_model.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bebbaf9991b437690e1fe28127e694671226e120ee0c8daebaa3991b63372031
3
+ size 46804649