CodeWithKyrian / transformers-php

Transformers PHP is a toolkit for PHP developers to add machine learning magic to their projects easily.
https://codewithkyrian.github.io/transformers-php/
Apache License 2.0
472 stars 28 forks source link

Background-removal throws error: Unknown model class for model type SegformerForSemanticSegmentation. Using base class PreTrainedModel. #66

Closed barryvdh closed 2 weeks ago

barryvdh commented 2 weeks ago

System Info

Macbook Pro M2 , PHP 8.2

PHP Version

8.2.19

Environment/Platform

Description

When running https://github.com/CodeWithKyrian/transformers-php/blob/main/examples/misc/background-removal.php I get the following error: Unknown model class for model type SegformerForSemanticSegmentation. Using base class PreTrainedModel.

Would be good to include the correct class in the example

Reproduction

Run the script from examples/misc/background-removal.php

CodeWithKyrian commented 2 weeks ago

Yes, this is a known issue when running models that have a model_type in their config that isn’t included in the officially supported list. Initially, I had it trigger a E_USER_WARNING, which typically doesn’t throw exceptions. However, when error_reporting is set to E_ALL, it does. During my testing, I didn’t have E_ALL enabled, so when I tried it in another project where it was set, I realized the warning could cause issues, leading me to remove it entirely.

For now, I’ve applied this update in the main branch, though I haven’t tagged a new release yet. Could you please use the main branch and test it until the new release is tagged? (should be in a few hours time)

That said, I still think it’s important to inform users, and I’m considering reintroducing a notification system in the future, possibly through logging that external services can hook into, or something like that

barryvdh commented 2 weeks ago

Yeah that works. I could work around it by silencing it using @ but that would prevent other errors. THanks!