Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A TypeError #71

Open
Antonio1228 opened this issue Mar 14, 2024 · 3 comments
Open

A TypeError #71

Antonio1228 opened this issue Mar 14, 2024 · 3 comments

Comments

@Antonio1228
Copy link

I have a TypeError while using the facetorch_notebook_demo.ipynb.
After this line{"asctime": "2024-03-14 11:20:40,111", "levelname": "INFO", "message": "Running FacePredictor: fer"}
The following error occured
TypeError: argmax(): argument 'input' (position 1) must be Tensor, not tuple

@tomas-gajarsky
Copy link
Owner

Hello,

Thank you for bringing this issue to my attention, and for providing details about the error you encountered while using facetorch_notebook_demo.ipynb.

I attempted to reproduce the issue on my end using the notebook and the default image, but I was not able to encounter the same error. This leads me to believe that the issue might be specific to the image or the data you're using as input. It's possible that the input processing part of the notebook might behave differently with different images, potentially leading to this error.

To better understand and resolve this issue, could you please share the image or the type of input you were using when you encountered this error? If there are privacy or size concerns with sharing the image directly, a similar example or more details about the characteristics of the input might also help diagnose the problem. This information will be crucial for me to replicate the error and find a suitable fix.

Again, thank you for your report, and I look forward to your response so we can resolve this issue together.

Best regards,
Tomas

@Antonio1228
Copy link
Author

Thank for your reply.

The input I use is same as the demo one.
I also encountered a permission error, but I solved it by downloading the models from Google drive and change the path_local in gpu.config.yml. I'm not sure whether it would affect or not.

Below are all the error message
`TypeError Traceback (most recent call last)
Cell In[13], line 4
2 analyzer = FaceAnalyzer(cfg.analyzer)
3 # warmup
----> 4 response = analyzer.run(
5 path_image=path_img_input,
6 batch_size=cfg.batch_size,
7 fix_img_size=cfg.fix_img_size,
8 return_img_data=False,
9 include_tensors=True,
10 path_output=path_img_output,
11 )

File c:\Users\09350.conda\envs\myenv\lib\contextlib.py:75, in ContextDecorator.call..inner(*args, **kwds)
72 @wraps(func)
73 def inner(*args, **kwds):
74 with self._recreate_cm():
---> 75 return func(*args, **kwds)

File c:\Users\09350.conda\envs\myenv\lib\site-packages\facetorch\analyzer\core.py:170, in FaceAnalyzer.run(self, image_source, path_image, batch_size, fix_img_size, return_img_data, include_tensors, path_output, tensor)
168 for predictor_name, predictor in self.predictors.items():
169 self.logger.info(f"Running FacePredictor: {predictor_name}")
--> 170 data = _predict_batch(data, predictor, predictor_name)
172 self.logger.info("Utilizing facial features")
...
--> 115 indices = torch.argmax(preds, dim=self.dim).cpu().numpy().tolist()
116 pred_list = self.create_pred_list(preds, indices)
118 return pred_list

TypeError: argmax(): argument 'input' (position 1) must be Tensor, not tuple`

@tomas-gajarsky
Copy link
Owner

Thanks for the detailed information on the error you're experiencing. The error message indicates that there's a problem with the expected data format in your code, likely caused by an issue with model loading or data processing.

Your manual download of the model and modification of path_local could potentially lead to unexpected results if the wrong model was downloaded or if the path was set incorrectly. Given that the error is related to a Tensor processing issue, I recommend ensuring that you've downloaded the correct model and updated the correct path in your gpu.config.yml.

To resolve this, you should:

  • Double-check that you're using FER model version 2, available at this link. If not, download it again and update the path accordingly.
  • If you're using a different model, make sure the configuration aligns with the correct settings for that model. Any discrepancy might lead to errors like the one you're experiencing.

After ensuring that you have the correct model and path, try running the code again to see if the error persists. If it does, let me know, and we can dig deeper to resolve the issue.

Thank you for your patience, and let me know if this helps.

Best regards,
Tomas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants