MAYANKS454 commited on
Commit
8518e0e
·
verified ·
1 Parent(s): 5ef4548

Upload 5 files

Browse files

UPLOADED 5 FILES

Files changed (5) hide show
  1. CNN_CIFAR10.ipynb +0 -0
  2. app.py +36 -0
  3. cnn_cifar10_model.h5 +3 -0
  4. requirements.txt +5 -0
  5. space.yml +3 -0
CNN_CIFAR10.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py : Streamlit Web App for CNN Image Classification
2
+
3
+ import streamlit as st
4
+ import tensorflow as tf
5
+ import numpy as np
6
+ from PIL import Image
7
+
8
+ # Load trained model
9
+ model = tf.keras.models.load_model("cnn_cifar10_model.h5")
10
+
11
+ # CIFAR-10 class labels
12
+ class_names = ['Airplane','Automobile','Bird','Cat','Deer',
13
+ 'Dog','Frog','Horse','Ship','Truck']
14
+
15
+ # Streamlit App UI
16
+ st.title("🖼️ CIFAR-10 Image Classifier")
17
+ st.write("Upload an image (32x32 or larger) to classify it into one of 10 classes.")
18
+
19
+ # File uploader
20
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg","jpeg","png"])
21
+
22
+ if uploaded_file is not None:
23
+ # Show uploaded image
24
+ img = Image.open(uploaded_file)
25
+ st.image(img, caption="Uploaded Image", width=150)
26
+
27
+ # Preprocess image
28
+ img = img.resize((32,32))
29
+ img_array = np.array(img)/255.0
30
+ img_array = np.expand_dims(img_array, axis=0)
31
+
32
+ # Prediction
33
+ prediction = model.predict(img_array)
34
+ pred_class = class_names[np.argmax(prediction)]
35
+
36
+ st.write(f"🎯 **Predicted Class:** {pred_class}")
cnn_cifar10_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a02b1abb1097ee8fb18d37e49009e247309195510d70dfbfc389cdfef7c7b9a1
3
+ size 1518296
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ tensorflow
3
+ numpy
4
+ pillow
5
+ matplotlib
space.yml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ sdk: streamlit
2
+ python_version: "3.9"
3
+ app_file: app.py