def get_predictions(region_crops):
if os.environ["IS_GPU"]:
caffe.set_device(0)
caffe.set_mode_gpu()
else:
caffe.set_mode_cpu()
classifier = caffe.Classifier(os.path.join(os.environ["TEXT_NOTEXT_MODELS_DIR"], "deploy.prototxt"),
os.path.join(os.environ["TEXT_NOTEXT_MODELS_DIR"], "weights.caffemodel"),
mean=np.array([104, 117, 123], dtype='f4'),
image_dims=[224, 224],
raw_scale=255.0,
channel_swap=[2, 1, 0])
LOGGER.info("Classifying " + str(len(region_crops)) + " inputs.")
predictions = classifier.predict(region_crops)
return predictions
region_classification.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录