Coder Social home page Coder Social logo

fabiocarrara / visual-sentiment-analysis Goto Github PK

View Code? Open in Web Editor NEW
38.0 1.0 7.0 12 KB

PyTorch port of models for Visual Sentiment Analysis pre-trained on the T4SA dataset.

Python 95.27% Shell 4.73%
visual-sentiment-analysis pytorch cross-media deep-learning convolutional-neural-networks

visual-sentiment-analysis's Introduction

Cross-Media Learning for Image Sentiment Analysis in the Wild

This repo contains the PyTorch-converted models for visual sentiment analysis trained on the T4SA (Twitter for Sentiment Analysis) dataset presented in [1].

[1] Vadicamo, L., Carrara, F., Cimino, A., Cresci, S., Dell'Orletta, F., Falchi, F. and Tesconi, M., 2017.
    Cross-media learning for image sentiment analysis in the wild.
    In Proceedings of the IEEE International Conference on Computer Vision Workshops (pp. 308-317).

Usage

  1. Install Requirements: PyTorch

  2. Download the pretrained models:

    ./download_models.sh
  3. Use the predict.py script to make predictions on images. Example:

    python predict.py images_list.txt --model vgg19_finetuned_all --batch-size 64 > predictions.csv

    The output file contains three columns representing the probability of each image belonging respectively to the negative, neutral, and positive classes in this order.

Converting the original Caffe models

We adopted MMdnn to convert caffe models to PyTorch. We recommend using the pre-built Docker image:

docker pull mmdnn/mmdnn:cpu.small

First, download the original models available at http://t4sa.it and extract them following this folder structure:

original-models/
├── hybrid_finetuned_all/
│   ├── deploy.prototxt
│   ├── mean.binaryproto
│   ├── snapshot_iter_34560.caffemodel
│   └── ...
├── hybrid_finetuned_fc6+/
│   ├── <same as above>
│   └── ...
├── vgg19_finetuned_all/
│   ├── <same as above>
│   └── ...
└── vgg19_finetuned_fc6+/
    ├── <same as above>
    └── ...

Then, run convert_models.sh:

docker run --rm -it -v $(pwd):/workspace -w /workspace mmdnn/mmdnn:cpu.small bash ./convert_models.sh

visual-sentiment-analysis's People

Contributors

fabiocarrara avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

visual-sentiment-analysis's Issues

Inquiries about the model operation

Hi the author of the great model,

I am a graduate student new to computational political communication and IT technology. I am very interested in your models, and am willing to acknowledge them in my research.
Still, I am a newcomer to the research practice and understandably encountered some problems.
I am doing it on Windows 10 Enterprise.

With the help of Google, I have successfully installed Git Bash and changed the directory to where the download_models.sh is in. I also think that I have successfully downloaded the models via the link (though I failed in using ./download_models.sh).

  • However, I encountered some difficulties when trying to implement the second sample code.
    image
    I have set the directory, but in Git Bash, it returns ModuleNotFoundError: No module named 'torch'
    image

  • Meanwhile, I also tried to operate the code in PyCharm Professional 2020.01. I only added Line 11 and Line 12 to ensure the directory is where the image_list.txt in.
    image
    image
    It also returns ERROR: predict.py: error: the following arguments are required: image_list.
    While I am trying to Google for help, I suspect that this may because 1) There should be something (should it be links or paths leading to someplace locally or on web?); 2) I placed the downloaded models in the wrong directory.

I would really appreciate it if you could kindly help me to solve this problem.
Starting to Learn these techs really needs a strong heart and warm help from know-hows.
Many thanks for your invaluable guidance!

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.