Skip to main content

ResMem

This is a package that wraps ResMem. This is a residual neural network that estimates the memorability of an image, on a scale of 0 to 1.

How to Use

To install from PyPI:

pip install resmem

The package contains two objects, ResMem itself, and a preprocessing transformer function built on torchvision.

from resmem import ResMem, transformer

model = ResMem(pretrained=True)

The transformer is designed to be used with pillow.

from PIL import Image

img = Image.open('./path/to/image') # This loads your image into memory
img = img.convert('RGB') 
# This will convert your image into RGB, for instance if it's a PNG (RGBA) or if it's black and white.

model.eval()
# Set the model to inference mode.

image_x = transformer(img)
# Run the preprocessing function

prediction = model(image_x.view(-1, 3, 227, 227))
# For a single image, the image must be reshaped into a batch
# with size 1.
# Get your prediction!

For more advanced usage, see the sample.py file in this repository.

Description of the Model

Historically, the next big advancement in using neural networks after AlexNet, the basis for MemNet, was ResNet. This allowed for convolutional neural networks to be built deeper, with more layers, without the gradient exploding or vanishing. Knowing that, let's try to include this in our model. What we will do is take a pre-trained ResNet, that is the whole thing, not just the convolutional features, and add it as an input feature for our regression step. The code for this is here.

ResMem Diagram

For the following discussion, while ResMem is initialized to a pre-trained optimum, I have allowed it to retrain for our problem. The thought is that given a larger set of parameters the final model should be more generalizable. Using weights and biases, we can run a hyperparameter sweep.

ResMem Testing

Here we can see much higher peaks, reaching into the range of 0.66-0.67! All of these runs were both trained and validated on a dataset that was constructed from both MemCat and LaMem databases.

Github Instructions

If you want to fiddle around with the raw github sourcecode, go right ahead. But be aware that we use git lfs for the model storage. You'll have to install the package at https://git-lfs.github.com/ and then run:

git lfs install
git lfs pull

to get access to the full model. Also note that the tests.py file that's included with this repository references a database that we, at this time, do not have permission to distribute, so consider that test file to be a guide rather than a hard-and-fast test.

Citation

@inproceedings{ResMem2021,
title = {Embracing New Techniques in Deep Learning for Predicting Image Memorability},
author = {Needell, Coen D. and Bainbridge, Wilma A.},
booktitle = {Proceedings of the Vision Sciences Society, 2021},
year = {2021},
publisher = {ARVO Journals},
url = {https://www.coeneedell.com/publication/vss2021/vss2021.pdf}
}

Metadata

Release files for resmem 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for resmem 1.1.6
File Size Uploaded
resmem-1.1.6.tar.gz 489.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for resmem 1.1.6
File Interpreter ABI Platform
resmem-1.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 978.2 MB

Release files / resmem-1.1.6.tar.gz

Download URL resmem-1.1.6.tar.gz
Size 489.1 MB
Tags Source
SHA-256 checksum
How to use checksums
405caf20b05e2bf86c5d06cad7523f255f07f1f1e161ae9c440fcad2ffd68c04
BLAKE2b-256 checksum
How to use checksums
f503a07080aafc86098c706da98a5da2a0144ea591b8876cc80e1cec66b125aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / resmem-1.1.6-py3-none-any.whl

Download URL resmem-1.1.6-py3-none-any.whl
Size 489.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2ed9d656280761215cde8f94a58197cdca523ccacb36fbd949edbea7a62c5572
BLAKE2b-256 checksum
How to use checksums
032d4f163c5ff98d1557191ff3d09d2ca843f7b9a75d8939a7cbb14670d2a4ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.1.6 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page