Code Monkey home page Code Monkey logo

a-classifier-with-pytorch's Introduction

A classifier with PyTorch

This code calls the models in Torchvision, and the classification network topic framework is derived from Torchvision. (And if you have any problem,you can send email to me:[email protected] or leave an error message in Issues.

from .alexnet import *
from .resnet import *
from .vgg import *
from .squeezenet import *
from .inception import *
from .densenet import *
from .googlenet import *
from .mobilenet import *
from .mnasnet import *
from .shufflenetv2 import *
from . import segmentation
from . import detection
from . import video

image info

#Several classification frameworks are available
AlexNetdensenet121densenet169densenet201densenet161GoogLeNetInception3mnasnet0_5mnasnet0_75mnasnet1_0mnasnet1_3MobileNetV2resnet18resnet34resnet50resnet101resnet152resnext50_32x4dresnext101_32x8dwide_resnet50_2wide_resnet101_2vgg11vgg13vgg16vgg19vgg11_bnvgg13_bnvgg16_bnvgg19_bn...........

The above is the classic network framework available within the models, and only for the classification networks within.This code is can take transfer learning , download the ImageNet pre trained initial model and then transfer learning in your code, and can be frozen convolution training only full connection layer, or global training, we only use the convolution of the classic network layer, and then the convolution results set on our lightweight classifier,

Train on our datasets

We used this classifier to predict the gender of the chicken, and we used vgg16,vgg16_bn,vgg19,vgg19_bn,resnet18,resnet34、densenet101 made a comparison。You can get our dataset here(谷歌云盘,所以大陆用户需翻墙访问,如不能翻墙,或有需要可发邮件给我)

Some sample images from Our dataset: image info

Train on Custom Dataset

-your datasets
 |--train
 |   |--label_1
 |   |--label_2
 |   |--label_n
 |--test or Val
     |--label_1
     |--label_2
     |--label_n

Your data set needs to look like the file structure above.And if you're not dichotomous, change the last output dimension from 2 to n。 Then execute the following command

python train.py --data_directory=your dataset --arch=vgg16

if you want to train on resnet or densenet and other, you can change the --arch=vgg16 to --arch=resnet34 or -- arch=densenet101 or other

Visualization of Training Process

Use tensorboard for visualization. After training, you can enter the following command for visualization.

Then visit the page that pops up on the command line,the following image will appear

tensorboard --logdirs=logs

image info

Visit the above page and download the corresponding CSV, then plot the training process according to csv_plot.py: image info You can adjust the parameters to make the training process more beautiful

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.