Defkhan5960 commited on
Commit
5311003
1 Parent(s): ca08efe

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +43 -0
  2. requiremenets.txt +5 -0
  3. student.h5 +3 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PIL import Image
3
+ import numpy as np
4
+ import tensorflow as tf
5
+ from keras.preprocessing.image import img_to_array
6
+
7
+ # Load the pre-trained model
8
+ model = tf.keras.models.load_model("student.h5")
9
+
10
+ # Define the class names
11
+ class_names = ["Diger", "MuhammetAliSimsek", "MuserrefSelcukOzdemir", "ZekeriyyaKoroglu"]
12
+
13
+ # Function to preprocess the image for model prediction
14
+ def preprocess_image(image_path):
15
+ img = Image.open(image_path).convert("RGB")
16
+ img = img.resize((224, 224)) # Ensure the image size matches the model input size
17
+ img_array = img_to_array(img)
18
+ img_array = np.expand_dims(img_array, axis=0)
19
+ return img_array # Normalize the pixel values
20
+
21
+ # Streamlit App
22
+ st.title("Student Recognition App")
23
+
24
+ # Upload image through Streamlit
25
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
26
+
27
+ if uploaded_file is not None:
28
+ # Display the uploaded image
29
+ st.image(uploaded_file, caption="Uploaded Image.", use_column_width=True)
30
+
31
+ # Preprocess the uploaded image
32
+ input_image = preprocess_image(uploaded_file)
33
+
34
+ # Make prediction using the model
35
+ predictions = model.predict(input_image)
36
+
37
+ # Get the predicted class
38
+ predicted_class_index = np.argmax(predictions)
39
+ predicted_class = class_names[predicted_class_index]
40
+
41
+ # Display the prediction result
42
+ st.write("Prediction Result:")
43
+ st.write(f"The person in the image is predicted as: {predicted_class}")
requiremenets.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit==1.23.1
2
+ pandas==1.5.3
3
+ plotly==5.0.0
4
+ tensorflow==2.12.0
5
+ matplotlib==3.7.0
student.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ea60f8dab75295cec5a58ffc9b139146b860cd9f58f9ce38c025c18832b4aa8
3
+ size 23218904