trashhpandaaaa commited on
Commit
fe34d3e
·
verified ·
1 Parent(s): a164b78

initial commit

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import tensorflow as tf
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ model = tf.keras.models.load_model('animal_classifier_model.h5')
7
+
8
+ class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
9
+
10
+ st.title('Animal Classifier')
11
+
12
+ uploaded_file = st.file_uploader("Choose an image...", type="jpg")
13
+
14
+ if uploaded_file is not None:
15
+ image = Image.open(uploaded_file)
16
+ st.image(image, caption='Uploaded Image', use_column_width=True)
17
+
18
+ image = image.resize((32, 32))
19
+ image_array = np.array(image) / 255.0
20
+ image_array = np.expand_dims(image_array, axis=0)
21
+
22
+ predictions = model.predict(image_array)
23
+ score = tf.nn.softmax(predictions[0])
24
+
25
+ st.write(f"Prediction: {class_names[np.argmax(score)]}")
26
+ st.write(f"Confidence: {100 * np.max(score):.2f}%")