mirror of
https://github.com/huggingface/transformers.git
synced 2025-10-20 17:13:56 +08:00
@ -724,7 +724,15 @@ def is_datasets_available() -> bool:
|
||||
|
||||
@lru_cache
|
||||
def is_detectron2_available() -> bool:
|
||||
return _is_package_available("detectron2")
|
||||
# We need this try/except block because otherwise after uninstalling the library, it stays available for some reason
|
||||
# i.e. `import detectron2` and `import detectron2.modeling` still work, even though the library is uninstalled
|
||||
# (the package exists but the objects are not reachable) - so here we explicitly try to import an object from it
|
||||
try:
|
||||
from detectron2.modeling import META_ARCH_REGISTRY # noqa
|
||||
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
@lru_cache
|
||||
|
Reference in New Issue
Block a user