Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Hate Speech Classification Model Guide
|
| 2 |
+
|
| 3 |
+
## Introduction
|
| 4 |
+
|
| 5 |
+
This document provides instructions for importing and using the hate speech classification model from Hugging Face in a Google Colab environment.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Steps for Setup
|
| 10 |
+
|
| 11 |
+
### 1. Import Necessary Libraries
|
| 12 |
+
```python
|
| 13 |
+
import tensorflow as tf
|
| 14 |
+
import tensorflow_hub as hub
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
### 2. Clone the Model Repository
|
| 18 |
+
|
| 19 |
+
`!git clone https://huggingface.co/dileepa/hate_speech_classification`
|
| 20 |
+
|
| 21 |
+
### 3. Load the Pre-trained Model
|
| 22 |
+
|
| 23 |
+
```
|
| 24 |
+
cnn_model = tf.keras.models.load_model(
|
| 25 |
+
'hate_speech_classification/model.h5',
|
| 26 |
+
custom_objects={'KerasLayer': hub.KerasLayer}
|
| 27 |
+
)
|
| 28 |
+
```
|
| 29 |
+
|
| 30 |
+
### 4. Example Usage
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
# Test prediction
|
| 34 |
+
sample_text = "Insert your text here"
|
| 35 |
+
|
| 36 |
+
result = cnn_model.predict([sample_text])
|
| 37 |
+
print(result)
|
| 38 |
+
```
|