Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

malaria_cell.py 1.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Thu Jul 22 23:03:04 2021
  4. @author: Abdiel W. Goni
  5. """
  6. import streamlit as st
  7. import tensorflow as tf
  8. import numpy as np
  9. #from keras.preprocessing import image
  10. #import cv2
  11. from PIL import Image, ImageOps
  12. model=tf.keras.models.load_model('malaria_cell.h5') # load model from
  13. st.write("""
  14. # Malaria Cell Classification
  15. """
  16. )
  17. def import_n_pred(image_data, model):
  18. size = (150,150)
  19. image = ImageOps.fit(image_data, size, Image.ANTIALIAS)
  20. img = np.asarray(image)
  21. reshape=img[np.newaxis,...]
  22. pred = model.predict(reshape)
  23. return pred
  24. upload_file = st.sidebar.file_uploader("Upload Cell Images", type="png")
  25. Generate_pred=st.sidebar.button("Predict")
  26. if Generate_pred:
  27. image=Image.open(upload_file)
  28. with st.beta_expander('Cell Image', expanded = True):
  29. st.image(image, use_column_width=True)
  30. pred=import_n_pred(image, model)
  31. labels = ['Parasitized', 'Uninfected']
  32. st.title("Prediction of image is {}".format(labels[np.argmax(pred)]))
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...