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 1013 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
25
26
27
28
29
30
  1. import streamlit as st
  2. from PIL import Image
  3. import tensorflow as tf
  4. import numpy as np
  5. import keras
  6. """
  7. # RRU Classifier Project
  8. """
  9. model = tf.keras.models.load_model(r"model.h5")
  10. # artifacts\training\model.h5
  11. uploaded_file = st.file_uploader("Choose a file")
  12. if uploaded_file is not None:
  13. # To read file as bytes:
  14. image = Image.open(uploaded_file)
  15. img = image.resize((300,300))
  16. img_array = np.array(img)
  17. img_array = np.expand_dims(img_array, axis=0) # [batch_size, row, col, channel]
  18. result = model.predict(img_array) # [[0.99, 0.01], [0.99, 0.01]]
  19. # y_classes = keras.np_utils.probas_to_classes(result)
  20. # y_pred=model.predict(np.expand_dims(img_array,axis=0))
  21. argmax_index = np.argmax(result, axis=1) # [0, 0]
  22. print(result)
  23. #print(f'print {y_pred}')
  24. print(argmax_index)
  25. print(argmax_index[0])
  26. if argmax_index[0] == 0:
  27. st.image(image, caption="predicted: RRU_ON_THE_GROUND")
  28. else:
  29. st.image(image, caption='predicted: RRU_ON_THE_TOP')
Tip!

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

Comments

Loading...