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

app.py 750 B

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
  1. import streamlit as st
  2. import tensorflow as tf
  3. import numpy as np
  4. from PIL import Image
  5. """
  6. # deep Classifier project
  7. """
  8. model = tf.keras.models.load_model("model.h5")
  9. uploaded_file = st.file_uploader("Choose a file")
  10. if uploaded_file is not None:
  11. # To read file as bytes:
  12. image = Image.open(uploaded_file)
  13. img = image.resize((224,224))
  14. img_array = np.array(img)
  15. img_array = np.expand_dims(img_array, axis=0) # [batch_size, row, col, channel]
  16. result = model.predict(img_array) # [[0.99, 0.01], [0.99, 0.01]]
  17. argmax_index = np.argmax(result, axis=1) # [0, 0]
  18. if argmax_index[0] == 0:
  19. st.image(image, caption="predicted: Wearing Mask")
  20. else:
  21. st.image(image, caption='predicted: Not Wearing Mask')
Tip!

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

Comments

Loading...