• 大小: 3.29MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-09-13
  • 语言: 其他
  • 标签: 人工智能  

资源简介

基于基于pytorch的cnn水果分类器深度学习平台,后期博客会针对该程序做以讲解,同时平台的搭建可以参考我的第一篇博客

资源截图

代码片段和文件信息

from __future__ import print_function
from PIL import Image
import os
import sys
import numpy as np
import argparse

import torch.utils.data as data


class Fruit(data.Dataset):
    
    def __init__(self root_dir train=True transform=None):
        self.root_dir = os.path.abspath(root_dir)
        self.transform = transform
        self.train=train

        if (self.train):
            self.data = np.load(os.path.join(self.root_dir “train_data.npy“))
            self.labels = np.load(os.path.join(self.root_dir “train_labels.npy“))
        else:
            self.data = np.load(os.path.join(self.root_dir “validation_data.npy“))
            self.labels = np.load(os.path.join(self.root_dir “validation_labels.npy“))

        self.data = self.data.transpose((0 2 3 1))
    
    def __getitem__(self index):
        img target = self.data[index] self.labels[index]
        #img = Image.fromarray(img.astype(‘uint8‘))
        
        if self.transform is not None:
            img = self.transform(img)

        return img target

    def __len__(self):
        return (len(self.data))

     

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-03-28 23:33  fruit-classification-pytorch-master\
     文件        1203  2019-03-28 23:33  fruit-classification-pytorch-master\.gitignore
     文件        1084  2019-03-28 23:33  fruit-classification-pytorch-master\LICENSE
     文件        1455  2019-03-28 23:33  fruit-classification-pytorch-master\README.md
     文件        1111  2019-03-28 23:33  fruit-classification-pytorch-master\fruit_data.py
     文件        4090  2019-03-28 23:33  fruit-classification-pytorch-master\load_dataset.py
     目录           0  2019-03-28 23:33  fruit-classification-pytorch-master\logs\
     文件     1277608  2019-03-28 23:33  fruit-classification-pytorch-master\logs\training_log.txt
     目录           0  2019-03-28 23:33  fruit-classification-pytorch-master\model\
     文件     1689894  2019-03-28 23:33  fruit-classification-pytorch-master\model\fruit_model_optimizer_dict.pth
     文件     1689770  2019-03-28 23:33  fruit-classification-pytorch-master\model\fruit_model_state_dict.pth
     目录           0  2019-03-28 23:33  fruit-classification-pytorch-master\test\
     文件      266418  2019-03-28 23:33  fruit-classification-pytorch-master\test\experiment.csv
     文件         523  2019-03-28 23:33  fruit-classification-pytorch-master\test\generate_loss_report.py
     文件       15895  2019-03-28 23:33  fruit-classification-pytorch-master\test\test_image.png
     文件        1652  2019-03-28 23:33  fruit-classification-pytorch-master\test\test_image.py
     文件       15895  2019-03-28 23:33  fruit-classification-pytorch-master\test_image.png
     文件        4551  2019-03-28 23:33  fruit-classification-pytorch-master\train.py

评论

共有 条评论