20 行代码:Serverless 架构下用 Python 轻松搞定图像分类和预测
系统运维 2025-10-09 23:35:00
0

复制# -*- coding: utf-8 -*- from imageai.Prediction import ImagePrediction # 模型加载 prediction = ImagePrediction() prediction.setModelTypeAsResNet() prediction.setModelPath("resnet50_weights_tf_dim_ordering_tf_kernels.h5") prediction.loadModel() predictions,行代像分 probabilities = prediction.predictImage("./picture.jpg", result_count=5 ) for eachPrediction, eachProbability in zip(predictions, probabilities): print(str(eachPrediction) + " : " + str(eachProbability)) 1.2.3.4.5.6.7.8.9.10.11.12.