Instructions to use feyninc/FeyNobg with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- nobg
How to use feyninc/FeyNobg with nobg:
pip install nobg
# Option 1: use via the predict method from nobg import AutoModel, AutoProcessor model = AutoModel.from_pretrained("feyninc/FeyNobg").eval() processor = AutoProcessor.from_pretrained("feyninc/FeyNobg") cutout = model.predict(processor, "image.jpg")# Option 2: use the model and processor directly import torch from loadimg import load_img from nobg import AutoModel, AutoProcessor model = AutoModel.from_pretrained("feyninc/FeyNobg").eval() processor = AutoProcessor.from_pretrained("feyninc/FeyNobg") image = load_img("image.jpg").convert("RGB") inputs = processor(image, return_tensors="pt") with torch.no_grad(): outputs = model(pixel_values=inputs["pixel_values"]) alpha = processor.post_process_alpha_matting(outputs, target_sizes=[(image.height, image.width)])[0] processor.cutout(image, alpha).save("output.png") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -16,23 +16,38 @@ This model has been pushed to the Hub using the [PytorchModelHubMixin](https://h
|
|
| 16 |
|
| 17 |
Library: [nobg](https://github.com/feyninc/nobg)
|
| 18 |
|
| 19 |
-
## how to
|
| 20 |
```
|
| 21 |
pip install nobg
|
| 22 |
```
|
| 23 |
|
| 24 |
-
use the AutoModel class
|
| 25 |
```python
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
```
|
| 34 |
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
## Citation
|
| 37 |
If you use this model, please cite:
|
| 38 |
```bibtex
|
|
|
|
| 16 |
|
| 17 |
Library: [nobg](https://github.com/feyninc/nobg)
|
| 18 |
|
| 19 |
+
## how to use the model
|
| 20 |
```
|
| 21 |
pip install nobg
|
| 22 |
```
|
| 23 |
|
|
|
|
| 24 |
```python
|
| 25 |
+
import torch
|
| 26 |
+
from loadimg import load_img
|
| 27 |
+
from nobg import AutoModel, AutoProcessor
|
| 28 |
+
|
| 29 |
+
model = AutoModel.from_pretrained("feyninc/FeyNobg").eval()
|
| 30 |
+
processor = AutoProcessor.from_pretrained("feyninc/FeyNobg")
|
| 31 |
+
|
| 32 |
+
image = load_img("input.jpg").convert("RGB")
|
| 33 |
+
inputs = processor(image, return_tensors="pt")
|
| 34 |
+
|
| 35 |
+
with torch.no_grad():
|
| 36 |
+
outputs = model(pixel_values=inputs["pixel_values"])
|
| 37 |
+
|
| 38 |
+
alpha = processor.post_process_alpha_matting(
|
| 39 |
+
outputs, target_sizes=[(image.height, image.width)]
|
| 40 |
+
)[0]
|
| 41 |
+
processor.cutout(image, alpha).save("output.png")
|
| 42 |
```
|
| 43 |
|
| 44 |
|
| 45 |
+

|
| 46 |
+
|
| 47 |
+

|
| 48 |
+
|
| 49 |
+

|
| 50 |
+
|
| 51 |
## Citation
|
| 52 |
If you use this model, please cite:
|
| 53 |
```bibtex
|