kandi background
Explore Kits

Facial-Expression-Recognition.Pytorch | CNN based pytorch implementation on facial expression recognition | Computer Vision library

 by   WuJie1010 Python Version: Current License: MIT

 by   WuJie1010 Python Version: Current License: MIT

Download this library from

kandi X-RAY | Facial-Expression-Recognition.Pytorch Summary

Facial-Expression-Recognition.Pytorch is a Python library typically used in Artificial Intelligence, Computer Vision, Pytorch applications. Facial-Expression-Recognition.Pytorch has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. However Facial-Expression-Recognition.Pytorch build file is not available. You can download it from GitHub.
A CNN based pytorch implementation on facial expression recognition (FER2013 and CK+), achieving 73.112% (state-of-the-art) in FER2013 and 94.64% in CK+ dataset
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • Facial-Expression-Recognition.Pytorch has a medium active ecosystem.
  • It has 1105 star(s) with 430 fork(s). There are 34 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 19 open issues and 99 have been closed. On average issues are closed in 31 days. There are 4 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of Facial-Expression-Recognition.Pytorch is current.
This Library - Support
Best in #Computer Vision
Average in #Computer Vision
This Library - Support
Best in #Computer Vision
Average in #Computer Vision

quality kandi Quality

  • Facial-Expression-Recognition.Pytorch has 0 bugs and 0 code smells.
This Library - Quality
Best in #Computer Vision
Average in #Computer Vision
This Library - Quality
Best in #Computer Vision
Average in #Computer Vision

securitySecurity

  • Facial-Expression-Recognition.Pytorch has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Facial-Expression-Recognition.Pytorch code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
This Library - Security
Best in #Computer Vision
Average in #Computer Vision
This Library - Security
Best in #Computer Vision
Average in #Computer Vision

license License

  • Facial-Expression-Recognition.Pytorch is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
This Library - License
Best in #Computer Vision
Average in #Computer Vision
This Library - License
Best in #Computer Vision
Average in #Computer Vision

buildReuse

  • Facial-Expression-Recognition.Pytorch releases are not available. You will need to build from source code and install.
  • Facial-Expression-Recognition.Pytorch has no build file. You will be need to create the build yourself to build the component from source.
  • Facial-Expression-Recognition.Pytorch saves you 619 person hours of effort in developing the same functionality from scratch.
  • It has 1440 lines of code, 92 functions and 17 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
This Library - Reuse
Best in #Computer Vision
Average in #Computer Vision
This Library - Reuse
Best in #Computer Vision
Average in #Computer Vision
Top functions reviewed by kandi - BETA

kandi has reviewed Facial-Expression-Recognition.Pytorch and discovered the below as its top functions. This is intended to give you an instant insight into Facial-Expression-Recognition.Pytorch implemented functionality, and help decide if they suit your requirements.

  • Convert image to PIL image .
  • Convert a PIL Image into a torch . Image .
  • This function runs the test .
  • Adjust the hue of an image .
  • The private test function .
  • Calculate public test accuracy .
  • Print a progress bar .
  • Train the model .
  • Resize a PIL Image .
  • Crop an image .

Facial-Expression-Recognition.Pytorch Key Features

A CNN based pytorch implementation on facial expression recognition (FER2013 and CK+), achieving 73.112% (state-of-the-art) in FER2013 and 94.64% in CK+ dataset

nn.Linear should be mismatch, but it works successfully

copy iconCopydownload iconDownload
def forward(self, x):
    out = self.features(x) # torch.Size([1, 512, 7, 7])
    out = out.view(out.size(0), -1)  # torch.Size([1, 25088])
    out = F.dropout(out, p=0.5, training=self.training)  # torch.Size([1, 25088])
    out = self.classifier(out)  # RuntimeError: size mismatch, m1: [1 x 25088], m2: [512 x 7]
    return out
self.classifier = nn.Linear(25088, 7)
-----------------------
def forward(self, x):
    out = self.features(x) # torch.Size([1, 512, 7, 7])
    out = out.view(out.size(0), -1)  # torch.Size([1, 25088])
    out = F.dropout(out, p=0.5, training=self.training)  # torch.Size([1, 25088])
    out = self.classifier(out)  # RuntimeError: size mismatch, m1: [1 x 25088], m2: [512 x 7]
    return out
self.classifier = nn.Linear(25088, 7)

Community Discussions

Trending Discussions on Facial-Expression-Recognition.Pytorch
  • nn.Linear should be mismatch, but it works successfully
Trending Discussions on Facial-Expression-Recognition.Pytorch

QUESTION

nn.Linear should be mismatch, but it works successfully

Asked 2019-Apr-02 at 08:26

I'm confused about the in-feature of nn.linear. For out-feature of the model VGG-19's last nn.MaxPool2d, the tensor size is (512, 7, 7). The model below uses pooling function and resizes the tensor to (512, 49), then uses nn.linear(512, 7) directly. Why can't it work successfully without mismatch problem?

source


'''VGG11/13/16/19 in Pytorch.'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable


cfg = {
    'VGG11': [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
    'VGG13': [64, 64, 'M', 128, 128, 'M', 256, 256, 'M', 512, 512, 'M', 512, 512, 'M'],
    'VGG16': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512, 'M', 512, 512, 512, 'M'],
    'VGG19': [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 256, 'M', 512, 512, 512, 512, 'M', 512, 512, 512, 512, 'M'],
}


class VGG(nn.Module):
    def __init__(self, vgg_name):
        super(VGG, self).__init__()
        self.features = self._make_layers(cfg[vgg_name])
        self.classifier = nn.Linear(512, 7)

    def forward(self, x):
        out = self.features(x)
        out = out.view(out.size(0), -1)
        out = F.dropout(out, p=0.5, training=self.training)
        out = self.classifier(out)
        return out

    def _make_layers(self, cfg):
        layers = []
        in_channels = 3
        for x in cfg:
            if x == 'M':
                layers += [nn.MaxPool2d(kernel_size=2, stride=2)]
            else:
                layers += [nn.Conv2d(in_channels, x, kernel_size=3, padding=1),
                           nn.BatchNorm2d(x),
                           nn.ReLU(inplace=True)]
                in_channels = x
        layers += [nn.AvgPool2d(kernel_size=1, stride=1)]
        return nn.Sequential(*layers)

ANSWER

Answered 2019-Apr-02 at 08:01

Why is the assumption that this code works? I tested it, and got the following shapes, and the expected size mismatch error.

def forward(self, x):
    out = self.features(x) # torch.Size([1, 512, 7, 7])
    out = out.view(out.size(0), -1)  # torch.Size([1, 25088])
    out = F.dropout(out, p=0.5, training=self.training)  # torch.Size([1, 25088])
    out = self.classifier(out)  # RuntimeError: size mismatch, m1: [1 x 25088], m2: [512 x 7]
    return out

One mistake that you made with inferring the sizes, is that you omitted the batch dimension. That is why you may falsely conclude that the shape change with out.view(out.size(0), -1) is [512, 7, 7] -> [512, 49] instead the correct [b, 512, 7, 7] -> [b, 25088] where b is the batch size.

As expected when classifier is changed to

self.classifier = nn.Linear(25088, 7)

then the forward function works, no size mismatch error.

Source https://stackoverflow.com/questions/55462619

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install Facial-Expression-Recognition.Pytorch

You can download it from GitHub.
You can use Facial-Expression-Recognition.Pytorch like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Share this Page

share link
Reuse Pre-built Kits with Facial-Expression-Recognition.Pytorch
Compare Computer Vision Libraries with Highest Support
Compare Computer Vision Libraries with Highest Security
Compare Computer Vision Libraries with Permissive License
Compare Computer Vision Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.