【目标检测】基于深度学习的植物中草药智能识别系统【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界面+数据集+训练代码】

相关推荐
AI玫瑰助手3 分钟前
Python运算符:逻辑运算符(and/or/not)的短路特性
开发语言·python·信息可视化
是梦终空3 分钟前
计算机源码274—基于深度学习的中医舌象智能识别与健康管理系统(源代码+数据库+12000字论文)
人工智能·python·深度学习·opencv·django·vue·springboot
明志数科4 分钟前
具身智能数据标注工具对比评测:6大平台横向测评
开发语言·python
杨超越luckly7 分钟前
HTML应用指南:利用GET请求获取智己汽车门店位置信息
python·arcgis·html·汽车·数据可视化
码界筑梦坊8 分钟前
132-基于Python的中老年体检数据可视化分析系统
开发语言·python·信息可视化·flask·毕业设计
大飞记Python10 分钟前
【2026更新】Python基础学习指南(AI版)——06函数
开发语言·人工智能·python
xing-xing12 分钟前
Anaconda学习总结
python
爱吃苹果的梨叔15 分钟前
2026分布式坐席系统推荐:指挥中心、调度中心、机房集中管控该怎么选?
python
liuhl091016 分钟前
Python 列表推导式
python
测试19987 小时前
软件测试 - 单元测试总结
自动化测试·软件测试·python·测试工具·职场和发展·单元测试·测试用例