/
sat1988
/
MachineVision
Обзор
Документация
Войти
/
sat1988
/
MachineVision
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
task07/test_text.py
56 строк
2 KB
Oleg Chorakaev
Добавлен 7 пример
26 июл 2025, 16:13
26 июл 2025, 16:13
0a00484
Код
Авторство
О чём код?
import os os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" import numpy as np import cv2 from tqdm import tqdm import tensorflow as tf def create_dir(path): if not os.path.exists(path): os.makedirs(path) """ Global parameters """ H = 640 W = 640 """ Seeding """ np.random.seed(42) tf.random.set_seed(42) """ Directory for storing files """ create_dir("results") model = tf.keras.models.load_model(os.path.join("files", "model.keras")) file = "adfbecd6-dc58-40cf-b8fa-de1305046cdd.jpg" image = cv2.imread("images/"+ file, cv2.IMREAD_COLOR) x = cv2.resize(image, (W, H)) x = (x - 127.5) / 127.5 x = np.expand_dims(x, axis=0) predictions = model.predict(x) print('размерность прогнозов:', predictions.shape) pred_bbox = predictions[-1] print (pred_bbox) #0.5,0.47890625,0.96796875,0.434375 file = "10a0ce75-b29b-4f29-a6ca-3e018f52f467.jpg" image = cv2.imread("images/"+ file, cv2.IMREAD_COLOR) x = cv2.resize(image, (W, H)) x = (x - 127.5) / 127.5 x = np.expand_dims(x, axis=0) predictions = model.predict(x) print('размерность прогнозов:', predictions.shape) pred_bbox = predictions[-1] print (pred_bbox) #0.46484375,0.44609375,0.1953125,0.125 file = "e6c7f1fd-7585-4211-a565-7ae2729e3c32.jpg" image = cv2.imread("images/"+ file, cv2.IMREAD_COLOR) x = cv2.resize(image, (W, H)) x = (x - 127.5) / 127.5 x = np.expand_dims(x, axis=0) predictions = model.predict(x) print('размерность прогнозов:', predictions.shape) pred_bbox = predictions[-1] print (pred_bbox) #0.2203125,0.146875,0.1625,0.1828125