euagendas / m3inference

A deep learning system for demographic inference (gender, age, and individual/person) that was trained on massive Twitter dataset using profile images, screen names, names, and biographies
http://www.euagendas.org
GNU Affero General Public License v3.0
145 stars 57 forks source link

Convert GIF images to PNG during resizing #2

Closed zhuowei closed 4 years ago

zhuowei commented 5 years ago

Some old accounts use a GIF avatar, which can't be loaded into the model. Convert them to PNG during resizing.


Testing: Running m3webdemo on @TheFacesOfNotch, which uses a .gif avatar, previously causes an error; it works with this patch.

Running m3webdemo on other accounts (eg @Xbox, @AppleTV) still works.

computermacgyver commented 5 years ago

Thank you for reporting this. It seems that Twitter is serving PNG files with a ".gif" extension in some instances:

$ wget -nv -O - "https://pbs.twimg.com/profile_images/1811733200/fon_reasonably_small_400x400.gif" | head -c 4
�PNG

I never knew this. This fix will break if there are actual GIF files with a ".gif" extension, but my guess is that these don't exist on Twitter now. I'm going to do a quick trawl through recent tweets in the random public sample for profiles with .gif to confirm before merging.

Thank you!