Spaces:
Sleeping
Sleeping
| from graphbook import param, resource | |
| from transformers import AutoModelForImageSegmentation | |
| def rmbg_model(self): | |
| """ | |
| Loads the background removal model from the Hugging Face model hub. | |
| By default, we are using [briaai/RMBG-1.4](https://huggingface.co/briaai/RMBG-1.4). | |
| Args: | |
| model_name (str): The name of the RMBG model. | |
| use_cuda (bool): Whether to use CUDA acceleration. | |
| """ | |
| model = AutoModelForImageSegmentation.from_pretrained( | |
| self.model_name, trust_remote_code=True | |
| ) | |
| if self.use_cuda: | |
| return model.to("cuda") | |
| return model | |