urchade / GLiNER

Generalist and Lightweight Model for Named Entity Recognition (Extract any entity types from texts) @ NAACL 2024
https://arxiv.org/abs/2311.08526
Apache License 2.0
1.46k stars 126 forks source link

Change how the config file is loaded #206

Closed eriknovak closed 2 weeks ago

eriknovak commented 2 weeks ago

The PR changes how the config_file is opened and read (making it consistent with other parts of file loading in GLiNER).

Also, the change should resolve the following warning emitted when loading a GLiNER model:

/site-packages/gliner/model.py:783: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/runner/.cache/huggingface/hub/models--urchade--gliner_multi_pii-v1/snapshots/1fcf13e85f4eef5394e1fcd406cf2ca9ea82351d/gliner_config.json' mode='r' encoding='UTF-8'>
  config_ = json.load(open(config_file))
ResourceWarning: Enable tracemalloc to get the object allocation traceback