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

Error in infer_id() #4

Closed winstonll closed 4 years ago

winstonll commented 4 years ago

The following code

from m3inference import M3Twitter
m3 = M3Twitter()
m3.infer_id(243344789)

Led to the following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/winston/.local/lib/python3.7/site-packages/m3inference/m3twitter.py", line 179, in infer_id
    output = self.process_twitter(data, id=id)
  File "/home/winston/.local/lib/python3.7/site-packages/m3inference/m3twitter.py", line 229, in process_twitter
    pred = self.infer(data, batch_size=1, num_workers=1)
  File "/home/winston/.local/lib/python3.7/site-packages/m3inference/m3inference.py", line 125, in infer
    for batch in tqdm(dataloader, desc='Predicting...'):
  File "/home/winston/.local/lib/python3.7/site-packages/tqdm/std.py", line 1119, in __iter__
    for obj in iterable:
  File "/home/winston/.local/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/home/winston/.local/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data
    return self._process_data(data)
  File "/home/winston/.local/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data
    data.reraise()
  File "/home/winston/.local/lib/python3.7/site-packages/torch/_utils.py", line 394, in reraise
    raise self.exc_type(msg)
FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/winston/.local/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/winston/.local/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/winston/.local/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/winston/.local/lib/python3.7/site-packages/m3inference/dataset.py", line 37, in __getitem__
    return self._preprocess_data(data)
  File "/home/winston/.local/lib/python3.7/site-packages/m3inference/dataset.py", line 43, in _preprocess_data
    fig = self._image_loader(img_path)
  File "/home/winston/.local/lib/python3.7/site-packages/m3inference/dataset.py", line 91, in _image_loader
    image = Image.open(image_name)
  File "/home/winston/.local/lib/python3.7/site-packages/PIL/Image.py", line 2809, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/home/winston/m3/cache/indiealehouse_224x224.png'
zijwang commented 4 years ago

Hi @winstonll ! This is due to the resolution of the profile image of the Twitter account 243344789 is too low. I have updated the codebase to force downloading such images. Could you pull the update and see whether it works now?