Spaces:
Sleeping
Sleeping
Commit
·
94002ab
1
Parent(s):
9a60cb4
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
from keras.models import load_model
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
model = load_model('./model.hdf5')
|
| 7 |
+
|
| 8 |
+
st.title('Fire Detection Image')
|
| 9 |
+
|
| 10 |
+
uploaded_file = st.file_uploader("Choose an image: ", type="jpg")
|
| 11 |
+
|
| 12 |
+
if uploaded_file is not None:
|
| 13 |
+
img = Image.open(uploaded_file)
|
| 14 |
+
img = img.resize((256, 256))
|
| 15 |
+
img_array = np.array(img)
|
| 16 |
+
img_array = np.expand_dims(img_array, axis=0)
|
| 17 |
+
if st.button('Predict'):
|
| 18 |
+
prediction = model.predict(image_batch)
|
| 19 |
+
predicted_class_index = np.argmax(prediction)
|
| 20 |
+
class_labels = {0: 'COVID19', 1: 'NORMAL', 2: 'PNEUMONIA', 3: 'TURBERCULOSIS'}
|
| 21 |
+
predicted_class_label = class_labels[predicted_class_index]
|
| 22 |
+
st.write(predicted_class_label)
|