Instructions to use zguo0525/myshell_nsfw_filter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zguo0525/myshell_nsfw_filter with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="zguo0525/myshell_nsfw_filter") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("zguo0525/myshell_nsfw_filter") model = AutoModelForImageClassification.from_pretrained("zguo0525/myshell_nsfw_filter") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# `myshell_nsfw_filter` Image Classification with Hugging Face Transformers
|
| 2 |
+
|
| 3 |
+
This README demonstrates how to use the `myshell_nsfw_filter` model hosted on Hugging Face for image classification.
|
| 4 |
+
|
| 5 |
+
## Prerequisites
|
| 6 |
+
|
| 7 |
+
1. Install the required Python packages:
|
| 8 |
+
```bash
|
| 9 |
+
pip install transformers requests Pillow
|
| 10 |
+
```
|
| 11 |
+
|
| 12 |
+
## Example Usage
|
| 13 |
+
|
| 14 |
+
Here's a step-by-step Python code example to classify an image:
|
| 15 |
+
|
| 16 |
+
```python
|
| 17 |
+
from transformers import pipeline
|
| 18 |
+
import requests
|
| 19 |
+
from PIL import Image
|
| 20 |
+
from io import BytesIO
|
| 21 |
+
|
| 22 |
+
# 1. Load the pipeline for image classification
|
| 23 |
+
pipe = pipeline("image-classification", model="zguo0525/myshell_nsfw_filter")
|
| 24 |
+
|
| 25 |
+
# 2. Load the image into memory (assuming you have the URL for the image)
|
| 26 |
+
image_url = 'https://img-myshell.net/meinamix/red_hair_girl'
|
| 27 |
+
response = requests.get(image_url)
|
| 28 |
+
image = Image.open(BytesIO(response.content))
|
| 29 |
+
|
| 30 |
+
# 3. Use the pipeline to classify the image
|
| 31 |
+
results = pipe(image)
|
| 32 |
+
|
| 33 |
+
# 4. Print the results
|
| 34 |
+
label = results[0]['label']
|
| 35 |
+
score = results[0]['score']
|
| 36 |
+
print(f"{label}: {score:.4f}")
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
## Conclusion
|
| 40 |
+
|
| 41 |
+
Using the Hugging Face Transformers library, it's straightforward to load and classify images with the `myshell_nsfw_filter` model. This README showcased a simple example, and you can easily adapt it for your own images or applications!
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
You can use this content for the README.md file in your repository. This provides a clear introduction and step-by-step guidance for users looking to leverage your model.
|