Update README.md
Browse files
README.md
CHANGED
|
@@ -1,159 +1,71 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
### Command Line Interface
|
| 74 |
-
|
| 75 |
-
For interactive testing:
|
| 76 |
-
```bash
|
| 77 |
-
python CLI_interactive_test.py
|
| 78 |
-
```
|
| 79 |
-
|
| 80 |
-
For model training:
|
| 81 |
-
```bash
|
| 82 |
-
python train.py
|
| 83 |
-
```
|
| 84 |
-
|
| 85 |
-
For running tests:
|
| 86 |
-
```bash
|
| 87 |
-
python test_model.py
|
| 88 |
-
```
|
| 89 |
-
|
| 90 |
-
## ποΈ Project Structure
|
| 91 |
-
|
| 92 |
-
```
|
| 93 |
-
βββ app.py # Streamlit web application
|
| 94 |
-
βββ CLI_interactive_test.py # Command line interface
|
| 95 |
-
βββ train.py # Model training script
|
| 96 |
-
βββ test_model.py # Model testing utilities
|
| 97 |
-
βββ cuda.py # CUDA availability check
|
| 98 |
-
βββ requirements.txt # Project dependencies
|
| 99 |
-
βββ setup.py # Package setup configuration
|
| 100 |
-
βββ Dockerfile # Docker configuration for containerization
|
| 101 |
-
βββ .dockerignore # Files to exclude from Docker image
|
| 102 |
-
βββ .space # Hugging Face Spaces configuration
|
| 103 |
-
βββ DEPLOY_TO_HUGGINGFACE.md # Deployment instructions for Hugging Face
|
| 104 |
-
βββ deploy_to_huggingface.sh # Script to help with Hugging Face deployment
|
| 105 |
-
βββ src/ # Source code directory
|
| 106 |
-
βββ models/ # Saved model checkpoints
|
| 107 |
-
βββ data/ # Training and test datasets
|
| 108 |
-
```
|
| 109 |
-
|
| 110 |
-
## π§ Model Architecture
|
| 111 |
-
|
| 112 |
-
The project uses a fine-tuned BERT model (bert-base-uncased) with additional classification layers to detect different types of toxicity in text. The model is implemented using PyTorch and the Transformers library.
|
| 113 |
-
|
| 114 |
-
Key components:
|
| 115 |
-
- BERT base model for text encoding
|
| 116 |
-
- Custom classification head for toxicity detection
|
| 117 |
-
- Multi-label classification support
|
| 118 |
-
- Real-time inference capabilities
|
| 119 |
-
|
| 120 |
-
## π Performance
|
| 121 |
-
|
| 122 |
-
The model is trained to classify text into multiple toxicity categories with high accuracy. It can process text in real-time and provides confidence scores for each category of toxicity:
|
| 123 |
-
- Toxic
|
| 124 |
-
- Severe Toxic
|
| 125 |
-
- Obscene
|
| 126 |
-
- Threat
|
| 127 |
-
- Insult
|
| 128 |
-
- Identity Hate
|
| 129 |
-
|
| 130 |
-
## π» Dependencies
|
| 131 |
-
|
| 132 |
-
Key dependencies include:
|
| 133 |
-
- transformers >= 4.35.0
|
| 134 |
-
- torch >= 1.9.0
|
| 135 |
-
- streamlit >= 1.24.0
|
| 136 |
-
- fastapi >= 0.68.0
|
| 137 |
-
- plotly >= 5.13.0
|
| 138 |
-
- pandas >= 1.3.0
|
| 139 |
-
- numpy >= 1.19.0
|
| 140 |
-
|
| 141 |
-
## π€ Contributing
|
| 142 |
-
|
| 143 |
-
Contributions are welcome! Please feel free to submit a Pull Request. Here's how you can contribute:
|
| 144 |
-
1. Fork the repository
|
| 145 |
-
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
|
| 146 |
-
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
|
| 147 |
-
4. Push to the branch (`git push origin feature/AmazingFeature`)
|
| 148 |
-
5. Open a Pull Request
|
| 149 |
-
|
| 150 |
-
## π License
|
| 151 |
-
|
| 152 |
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
| 153 |
-
|
| 154 |
-
## π Acknowledgments
|
| 155 |
-
|
| 156 |
-
- Hugging Face for the Transformers library
|
| 157 |
-
- The BERT team at Google Research
|
| 158 |
-
- The Streamlit team for the excellent web framework
|
| 159 |
-
- The PyTorch team for the deep learning framework
|
|
|
|
| 1 |
+
---
|
| 2 |
+
# ======= Configuration Block (YAML Front Matter) =======
|
| 3 |
+
# This section configures your Hugging Face Space.
|
| 4 |
+
# Values are based on the documentation you provided.
|
| 5 |
+
|
| 6 |
+
# --- Basic Info ---
|
| 7 |
+
# (Required) Title shown on the Space page and card
|
| 8 |
+
title: My Awesome App
|
| 9 |
+
# (Required) Emoji shown on the Space card (find emojis at https://getemoji.com/)
|
| 10 |
+
emoji: π
|
| 11 |
+
# (Optional) Color gradient for the Space card
|
| 12 |
+
colorFrom: blue
|
| 13 |
+
colorTo: green
|
| 14 |
+
# (Required) The type of application: gradio, streamlit, docker, or static
|
| 15 |
+
sdk: gradio # IMPORTANT: Change this if you are using Streamlit, Docker, or just HTML files!
|
| 16 |
+
# (Optional) Specify the Python version (default is 3.10)
|
| 17 |
+
python_version: 3.10
|
| 18 |
+
# (Optional) Specify the SDK version (e.g., Gradio version). If omitted, HF uses a default.
|
| 19 |
+
# sdk_version: 4.1.0 # Uncomment and set if you need a specific Gradio/Streamlit version
|
| 20 |
+
# (Optional) Specify the main application file (default is app.py for Gradio/Streamlit)
|
| 21 |
+
# app_file: my_application_script.py # Uncomment and change if your main file isn't called app.py
|
| 22 |
+
|
| 23 |
+
# --- Optional Info ---
|
| 24 |
+
# (Optional) A short description for the Space card
|
| 25 |
+
short_description: A cool demo of [Your App's Technology/Purpose].
|
| 26 |
+
# (Optional) List of tags to help others find your Space
|
| 27 |
+
# tags: [text-generation, machine-learning, demo] # Uncomment and add relevant tags
|
| 28 |
+
# (Optional) Keep this Space pinned at the top of your profile
|
| 29 |
+
# pinned: false
|
| 30 |
+
|
| 31 |
+
# ======= End of Configuration Block =======
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
# ======= Description Content (Markdown) =======
|
| 35 |
+
# This part is displayed on your Space's page.
|
| 36 |
+
# Write in Markdown format (https://www.markdownguide.org/basic-syntax/).
|
| 37 |
+
|
| 38 |
+
# My Awesome App π
|
| 39 |
+
|
| 40 |
+
**β‘οΈ Short Description:** [**Replace this with a one-sentence description of what your application does.**]
|
| 41 |
+
*Example: This Space uses Gradio to demonstrate a simple image classification model.*
|
| 42 |
+
|
| 43 |
+
## π€ What does it do?
|
| 44 |
+
|
| 45 |
+
[**Replace this with a more detailed explanation of your application. What problem does it solve? What features does it have?**]
|
| 46 |
+
*Example:*
|
| 47 |
+
* *Upload an image.*
|
| 48 |
+
* *The app predicts what object is in the image.*
|
| 49 |
+
* *It shows the top 3 predictions and their confidence scores.*
|
| 50 |
+
|
| 51 |
+
## π How to use it?
|
| 52 |
+
|
| 53 |
+
[**Replace this with simple instructions for users.**]
|
| 54 |
+
*Example:*
|
| 55 |
+
*1. Click on the 'Upload Image' box or drag and drop an image file.*
|
| 56 |
+
*2. Wait for the prediction to appear below.*
|
| 57 |
+
*3. That's it!*
|
| 58 |
+
|
| 59 |
+
## π οΈ Dependencies
|
| 60 |
+
|
| 61 |
+
This application requires the libraries listed in the `requirements.txt` file. Hugging Face Spaces automatically installs these when the Space builds.
|
| 62 |
+
|
| 63 |
+
## π Files
|
| 64 |
+
|
| 65 |
+
* `app.py`: The main application code (using Gradio/Streamlit). [**Update if your filename is different!**]
|
| 66 |
+
* `requirements.txt`: Lists the Python libraries needed.
|
| 67 |
+
* `README.md`: This file (configuration and description).
|
| 68 |
+
* [**Add any other important files here, like model files, helper scripts, etc.**]
|
| 69 |
+
|
| 70 |
+
---
|
| 71 |
+
*Space created by [Your Name/Username]*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|