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

main.py 886 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
31
32
33
  1. import os
  2. import numpy as np
  3. import pandas as pd
  4. import matplotlib.pyplot as plt
  5. import tensorflow as tf
  6. from tensorflow.keras.models import load_model
  7. import cv2
  8. import mlflow
  9. from utils import image_to_pixels, preprocess_pixels
  10. import re
  11. model = load_model('./models/cnn_6.h5')
  12. pattern = r"sudoku-*"
  13. rel_path = './images/toy/'
  14. my_digits = [filename for filename in os.listdir(rel_path) if re.match (pattern, filename)]
  15. for image_file in my_digits:
  16. image = cv2.imread(rel_path + image_file)
  17. image = image_to_pixels(image)
  18. image = preprocess_pixels(image)
  19. prediction = model.predict(image)
  20. prediction_label = prediction.argmax() + 1
  21. predicted_probability = prediction.max()
  22. print(f'{image_file = }')
  23. print(f'{prediction.round(3) = }')
  24. print(f'{prediction_label = }')
  25. print(f'{predicted_probability = }')
  26. print()
  27. print()
  28. print()
Tip!

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

Comments

Loading...