AI Media and Misinformation Content Analysis Tool
Project description
AMMICO - AI Media and Misinformation Content Analysis Tool
This package extracts data from images such as social media posts that contain an image part and a text part. The analysis can generate a very large number of features, depending on the user input. See our paper for a more in-depth description.
This project is currently under development!
Use pre-processed image files such as social media posts with comments and process to collect information:
- Text extraction from the images
- Language detection
- Translation into English or other languages
- Cleaning of the text, spell-check
- Sentiment analysis
- Named entity recognition
- Topic analysis
- Content extraction from the images
- Textual summary of the image content ("image caption") that can be analyzed further using the above tools
- Feature extraction from the images: User inputs query and images are matched to that query (both text and image query)
- Question answering
- Performing person and face recognition in images
- Face mask detection
- Probabilistic detection of age, gender and race
- Emotion recognition
- Color analysis
- Analyse hue and percentage of color on image
- Multimodal analysis
- Find best matches for image content or image similarity
- Cropping images to remove comments from posts
Installation
The AMMICO
package can be installed using pip:
pip install ammico
This will install the package and its dependencies locally. If after installation you get some errors when running some modules, please follow the instructions in the FAQ.
Usage
The main demonstration notebook can be found in the notebooks
folder and also on google colab: .
There are further sample notebooks in the notebooks
folder for the more experimental features:
- Topic analysis: Use the notebook
get-text-from-image.ipynb
to analyse the topics of the extraced text.
You can run this notebook on google colab:
Place the data files and google cloud vision API key in your google drive to access the data. - To crop social media posts use the
cropposts.ipynb
notebook. You can run this notebook on google colab:
Features
Text extraction
The text is extracted from the images using google-cloud-vision. For this, you need an API key. Set up your google account following the instructions on the google Vision AI website or as described here. You then need to export the location of the API key as an environment variable:
export GOOGLE_APPLICATION_CREDENTIALS="location of your .json"
The extracted text is then stored under the text
key (column when exporting a csv).
Googletrans is used to recognize the language automatically and translate into English. The text language and translated text is then stored under the text_language
and text_english
key (column when exporting a csv).
If you further want to analyse the text, you have to set the analyse_text
keyword to True
. In doing so, the text is then processed using spacy (tokenized, part-of-speech, lemma, ...). The English text is cleaned from numbers and unrecognized words (text_clean
), spelling of the English text is corrected (text_english_correct
), and further sentiment and subjectivity analysis are carried out (polarity
, subjectivity
). The latter two steps are carried out using TextBlob. For more information on the sentiment analysis using TextBlob see here.
The Hugging Face transformers library is used to perform another sentiment analysis, a text summary, and named entity recognition, using the transformers
pipeline.
Content extraction
The image content ("caption") is extracted using the LAVIS library. This library enables vision intelligence extraction using several state-of-the-art models such as BLIP and BLIP2, depending on the task and user selection. Further, it allows feature extraction from the images, where users can input textual and image queries, and the images in the database are matched to that query (multimodal search). Another option is question answering, where the user inputs a text question and the library finds the images that match the query.
Emotion recognition
Emotion recognition is carried out using the deepface and retinaface libraries. These libraries detect the presence of faces, as well as provide probabilistic assessment of their age, gender, race, and emotion based on several state-of-the-art models. It is also detected if the person is wearing a face mask - if they are, then no further detection is carried out as the mask affects the assessment acuracy. Because the detection of gender, race and age is carried out in simplistic categories (e.g., for gender, using only "male" and "female"), and because of the ethical implications of such assessments, users can only access this part of the tool if they agree with an ethical disclosure statement (see FAQ). Moreover, once users accept the disclosure, they can further set their own detection confidence threshholds.
Color/hue detection
Color detection is carried out using colorgram.py and colour for the distance metric. The colors can be classified into the main named colors/hues in the English language, that are red, green, blue, yellow, cyan, orange, purple, pink, brown, grey, white, black.
Cropping of posts
Social media posts can automatically be cropped to remove further comments on the page and restrict the textual content to the first comment only.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ammico-0.2.2.tar.gz
.
File metadata
- Download URL: ammico-0.2.2.tar.gz
- Upload date:
- Size: 13.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e89e89339b5db14d3446b50df868a61a2b4ad2beb37de2a780c32412db3726fc |
|
MD5 | f8d652e67a73fd7dbba96a9a578a7c92 |
|
BLAKE2b-256 | a5ece5e671a247ad79c2854dafd1c01ec61588f5d316ec52e3e92ae82c5291c9 |
Provenance
File details
Details for the file ammico-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: ammico-0.2.2-py3-none-any.whl
- Upload date:
- Size: 11.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5d72b470ff9f843063bbcadd27baa585667025c6eec9767ddff085dfeaaf96f |
|
MD5 | 955bee59e6e242f40e1547fdb65ab859 |
|
BLAKE2b-256 | b4ae47feeb2e29d8105828193f2d2467bb34adc5084b1ba27f4f26a7aa2f47aa |