博主介绍:✌全网粉丝10W+,前互联网大厂软件研发、集结硕博英豪成立工作室。专注于计算机相关专业项目实战6年之久,选择我们就是选择放心、选择安心毕业✌
> 🍅想要获取完整文章或者源码,或者代做,拉到文章底部即可与我联系了。🍅

点击查看作者主页,了解更多项目!

🍅感兴趣的可以先收藏起来,点赞、关注不迷路,大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助同学们顺利毕业 。🍅

1、毕业设计:2025年计算机专业毕业设计选题汇总(建议收藏)✅

2、大数据毕业设计:2025年选题大全 深度学习 python语言 JAVA语言 hadoop和spark(建议收藏)✅

1、项目介绍

技术栈:
Python语言、深度学习pytorch、ResNet神经网络模型、识别保存、准确率、pyqt

2、项目界面

(1)厨余垃圾

在这里插入图片描述

(2)其他垃圾

在这里插入图片描述

(3)其他垃圾
在这里插入图片描述

(4)有害垃圾
在这里插入图片描述

(5)厨余垃圾

在这里插入图片描述

(6)可回收物
在这里插入图片描述

3、项目说明

技术实现

  • 语言与框架:用 Python 语言开发,依托 PyTorch 深度学习框架构建模型,利用其自动求导、灵活构建网络层等特性,高效实现模型训练与推理 。
  • 模型选型:采用 ResNet 神经网络模型,它通过残差连接解决深层网络训练梯度消失、退化问题,能提取更丰富图像特征,提升分类精度 。
  • 功能关联:借助模型完成垃圾图像识别,输出识别结果并保存,计算准确率评估模型性能,用 PyQt 搭建可视化交互界面,让用户便捷操作 。

项目流程

  1. 交互入口:用户通过 PyQt 界面“选择图片按钮”上传垃圾图像,界面承担采集用户输入(图像)的功能 。
  2. 模型推理:点击“检测”,图像传入 ResNet 模型,模型基于预训练的特征提取与分类能力,判断垃圾类别(如示例中识别为“厨余垃圾/水果果肉” ),同时输出概率值(如 0.617 ,代表模型对该分类结果的置信程度 )。
  3. 结果呈现:“检测结果”区域展示类别与概率,下方控制台也会记录识别过程信息(图片路径、各分类概率等 ),供调试或分析;用户可依据需求,决定是否保存识别结果,完成分类后可通过“退出”关闭系统 。

应用价值

  • 实用场景:适用于家庭、社区垃圾初步分类,辅助环保人员快速分拣,或嵌入智能垃圾桶等设备,推动垃圾分类智能化 。
  • 技术意义:将深度学习模型落地到实际交互场景,验证 ResNet 在垃圾图像分类的有效性,也为同类图像分类(如工业废料、医疗垃圾细分 )项目提供开发思路,是 AI 助力环保的具体实践 。

4、核心代码

import os
import json

import torch
from PIL import Image
from torchvision import transforms
import matplotlib.pyplot as plt

from model import resnet34


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

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

    # load image
    img_path = "../data/val/bronchial normal cells/B2B-1-1-5.jpg"
    assert os.path.exists(img_path), "file: '{}' dose not exist.".format(img_path)
    img = Image.open(img_path)
    plt.imshow(img)
    # [N, C, H, W]
    img = data_transform(img)
    # expand batch dimension
    img = torch.unsqueeze(img, dim=0)

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

    with open(json_path, "r") as f:
        class_indict = json.load(f)

    # create model
    model = resnet34(num_classes=5).to(device)

    # load model weights
    weights_path = "./weights/1/best.pth"
    assert os.path.exists(weights_path), "file: '{}' dose not exist.".format(weights_path)
    model.load_state_dict(torch.load(weights_path, map_location=device))

    # prediction
    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()

    print_res = "class: {}   prob: {:.3}".format(class_indict[str(predict_cla)],
                                                 predict[predict_cla].numpy())
    plt.title(print_res)
    for i in range(len(predict)):
        print("class: {:10}   prob: {:.3}".format(class_indict[str(i)],
                                                  predict[i].numpy()))
    plt.show()


if __name__ == '__main__':
    main()

5、源码获取方式

🍅由于篇幅限制,获取完整文章或源码、代做项目的,查看我的【用户名】、【专栏名称】、【顶部选题链接】就可以找到我啦🍅

感兴趣的可以先收藏起来,点赞、关注不迷路,下方查看👇🏻获取联系方式👇🏻

Logo

码道开发者社区,聚焦华为云码道 CodeArts 代码智能体,沉淀 Agent、Skill、鸿蒙开发实战内容,供开发者查阅资料、交流技术、分享工程实践

更多推荐