ai修复图片 python_Python + AI 图片识别案例
根據CSDN人工智能頭條發的《10行代碼實現目標檢測》的文檔,實驗了一把圖片識別的小例子,挺有意思
原文鏈接:https://blog.csdn.net/guleileo/article/details/80767966
from imageai.Detection import ObjectDetection #導入 ImageAI 目標檢測類
import os
execution_path = os.getcwd()
detector = ObjectDetection() #定義目標檢測類
detector.setModelTypeAsRetinaNet() #將模型的類型設置為 RetinaNet
detector.setModelPath( os.path.join(execution_path , "resnet50_coco_best_v2.0.1.h5")) #將模型路徑設置為 RetinaNet 模型的路徑
detector.loadModel() #將模型加載到的目標檢測類
detections = detector.detectObjectsFromImage(input_image=os.path.join(execution_path , "image.jpg"), output_image_path=os.path.join(execution_path , "imagenew.jpg")) #調用目標檢測函數,解析輸入的和輸出的圖像路徑
for eachObject in detections: #迭代執行 detector.detectObjectsFromImage 函數并返回所有的結果
print(eachObject["name"] + " : " + eachObject["percentage_probability"] ) #打印出所檢測到的每個目標的名稱及其概率值
總結
以上是生活随笔為你收集整理的ai修复图片 python_Python + AI 图片识别案例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php获取视频时长
- 下一篇: 破解安卓图案锁屏密码