CoolFace
Apppublic

sjaswal/Cnn_Malaria_Detection_Model

sourceHugging Faceapache-2.0updated 2y agoView on Hugging Face
0likes
app.py43 linesDownload Raw Back to root
1import streamlit as st
2from keras.models import load_model
3from PIL import Image
4import numpy as np
5
6from util import classify, set_background
7
8
9#set_background('E:/maleria/background.jpeg')
10
11#set title
12st.title('Maleria Detection')
13
14
15#set header
16st.header('Please upload a Blood Sample image')
17
18#upload file
19file = st.file_uploader('', type=['jpeg', 'jpg', 'png'])
20
21#load classifier
22model = load_model('./keras_model.h5')
23
24
25#load class names
26with open('labels.txt', 'r') as f:
27    class_names = [a[:-1].split(' ')[1] for a in f.readlines()]
28    f.close()
29
30
31#display image
32if file is not None:
33    image = Image.open(file).convert('RGB')
34    st.image(image, use_column_width=True)
35
36
37    #classify image
38    class_name, conf_score = classify(image, model, class_names)
39
40
41    #write classification
42    st.write("## {}".format(class_name))
43    st.write("### score: {}%".format(int(conf_score * 1000) / 10))