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

系统简介:

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

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

系统界面:

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

python 复制代码
def main(img_path):
    import os
    os.environ['KMP_DUPLICATE_LIB_OK'] = 'TRUE'

    device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

    img_size = 224
    data_transform = transforms.Compose(
        [transforms.Resize(int(img_size * 1.143)),
         transforms.CenterCrop(img_size),
         transforms.ToTensor(),
         transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])

    assert os.path.exists(img_path), "file: '{}' dose not exist.".format(img_path)
    img = Image.open(img_path)
    plt.imshow(img)

    img = data_transform(img)
    img = torch.unsqueeze(img, dim=0)

    json_path = './class_indices.json'
    assert os.path.exists(json_path), "file: '{}' dose not exist.".format(json_path)

    json_file = open(json_path, "r")
    class_indict = json.load(json_file)

    # create model
    model = create_model(num_classes=67).to(device)
    # load model weights
    model_weight_path = "model-90.pth"
    model.load_state_dict(torch.load(model_weight_path, map_location=device))
    model.eval()
    with torch.no_grad():
        # predict class
        output = torch.squeeze(model(img.to(device))).cpu()
        predict = torch.softmax(output, dim=0)
        predict_cla = torch.argmax(predict).numpy()

    for i in range(len(predict)):
        print("class: {:10}   prob: {:.3}".format(class_indict[str(i)],
                                                  predict[i].numpy()))
    # plt.show()
    res = class_indict[str(list(predict.numpy()).index(max(predict.numpy())))]
    num= "%.2f" % (max(predict.numpy()) * 100) + "%"
    print(res,num)
    return res,max(predict.numpy())

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

相关推荐
2601_967980115 分钟前
wxPython 入门教程.pdf
python·wxpython·gui·教程·移植性
计算机毕业编程指导师18 分钟前
2027计算机毕设选题指南:网站AI化、大数据预测+算法(XGBoost/LightGBM)、深度学习三方向57题+选题方法论
大数据·python·计算机·毕业设计·课程设计·毕设选题·1024程序员节
李航198321 分钟前
DeepSeek AI建模(二)让AI建第一个模型
人工智能·python·计算机视觉·ai·ai编程
tellmewhoisi42 分钟前
深度学习13:反向传播4:输出层Softmax-with-Loss
人工智能·深度学习
小嘉丶学长1 小时前
Day06 · 数据类型与类型检测
开发语言·python·学习·1024程序员节
Jsundoku1 小时前
第三章 深度学习 -- 神经网络基础
人工智能·深度学习·神经网络
lucas_AI2 小时前
PyTorch、JAX 全中招:Softmax 藏了两个数值 Bug,DeepMind 用十余行代码修好了
深度学习
计算机毕业编程指导师2 小时前
基于深度学习的电子垃圾与混合材料图像分类系统实战:ResNet-50迁移学习+Django部署+三种识别入口完整方案
python·深度学习·毕业设计·resnet·课程设计·图像分类·电子垃圾
外收内放2 小时前
FastAPI猜字谜实战(5):会话管理
开发语言·python·学习·fastapi
垆边人似月.2 小时前
选型与快速跑通(Tesseract / EasyOCR / PaddleOCR)
前端·python