Spaces:
Running
Running
import os | |
import pooch | |
from . import BiRefNetSessionGeneral | |
class BiRefNetSessionCOD(BiRefNetSessionGeneral): | |
""" | |
This class represents a BiRefNet-COD session, which is a subclass of BiRefNetSessionGeneral. | |
""" | |
def download_models(cls, *args, **kwargs): | |
""" | |
Downloads the BiRefNet-COD model file from a specific URL and saves it. | |
Parameters: | |
*args: Additional positional arguments. | |
**kwargs: Additional keyword arguments. | |
Returns: | |
str: The path to the downloaded model file. | |
""" | |
fname = f"{cls.name(*args, **kwargs)}.onnx" | |
pooch.retrieve( | |
"https://github.com/danielgatis/rembg/releases/download/v0.0.0/BiRefNet-COD-epoch_125.onnx", | |
( | |
None | |
if cls.checksum_disabled(*args, **kwargs) | |
else "md5:f6d0d21ca89d287f17e7afe9f5fd3b45" | |
), | |
fname=fname, | |
path=cls.u2net_home(*args, **kwargs), | |
progressbar=True, | |
) | |
return os.path.join(cls.u2net_home(*args, **kwargs), fname) | |
def name(cls, *args, **kwargs): | |
""" | |
Returns the name of the BiRefNet-COD session. | |
Parameters: | |
*args: Additional positional arguments. | |
**kwargs: Additional keyword arguments. | |
Returns: | |
str: The name of the session. | |
""" | |
return "birefnet-cod" | |