• 【目标检测】基于深度学习的植物中草药智能识别系统【python源码+Pyqt5界面+数据集+训练代码 MX_001期】


    系统简介:

    这是一款基于深度学习技术的植物草药智能识别系统。系统通过分析植物草药的图像,能够准确地识别出不同种类的草药,并提供相关的信息和用途。用户只需将植物草药的图像上传至系统,即可快速获得识别结果。

    系统利用先进的深度学习算法,对植物草药图像进行特征提取和模式识别,从而实现高精度的分类和识别。同时系统具备良好的用户界面和友好的交互体验,使得用户能够轻松使用并获得所需的识别结果。

    系统界面:

    部分代码(完整代码在最后):

    1. def main(img_path):
    2. import os
    3. os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'
    4. device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
    5. img_size = 224
    6. data_transform = transforms.Compose(
    7. [transforms.Resize(int(img_size * 1.143)),
    8. transforms.CenterCrop(img_size),
    9. transforms.ToTensor(),
    10. transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
    11. assert os.path.exists(img_path), "file: '{}' dose not exist.".format(img_path)
    12. img = Image.open(img_path)
    13. plt.imshow(img)
    14. img = data_transform(img)
    15. img = torch.unsqueeze(img, dim=0)
    16. json_path = './class_indices.json'
    17. assert os.path.exists(json_path), "file: '{}' dose not exist.".format(json_path)
    18. json_file = open(json_path, "r")
    19. class_indict = json.load(json_file)
    20. # create model
    21. model = create_model(num_classes=67).to(device)
    22. # load model weights
    23. model_weight_path = "model-90.pth"
    24. model.load_state_dict(torch.load(model_weight_path, map_location=device))
    25. model.eval()
    26. with torch.no_grad():
    27. # predict class
    28. output = torch.squeeze(model(img.to(device))).cpu()
    29. predict = torch.softmax(output, dim=0)
    30. predict_cla = torch.argmax(predict).numpy()
    31. for i in range(len(predict)):
    32. print("class: {:10} prob: {:.3}".format(class_indict[str(i)],
    33. predict[i].numpy()))
    34. # plt.show()
    35. res = class_indict[str(list(predict.numpy()).index(max(predict.numpy())))]
    36. num= "%.2f" % (max(predict.numpy()) * 100) + "%"
    37. print(res,num)
    38. return res,max(predict.numpy())

    完整源码:【目标检测】基于深度学习的植物中草药智能识别系统【python源码+Pyqt5界面+数据集+训练代码】

  • 相关阅读:
    打字母的时候,字母间距突然变大,解决办法
    每天面试题,第二天 字符串相关
    Kotlin 进阶版 协程
    里氏替换原则~
    HCIA 笔记(1)
    人工智能数学基础--概率与统计11:离散随机变量的超几何分布和负二项分布
    若依-整合WebSocket
    vite项目运行后只显示主机地址
    事件对象(Event对象)
    【EI会议征稿】第三届图像,信号处理与模式识别国际学术会议(ISPP 2024)
  • 原文地址:https://blog.csdn.net/ANDROID6666666/article/details/139335426