Spaces:
Runtime error
Runtime error
Update README.md
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: π
|
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 5.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
@@ -14,4 +14,149 @@ hf_oauth_scopes:
|
|
| 14 |
- inference-api
|
| 15 |
---
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
colorFrom: gray
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 5.25.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 14 |
- inference-api
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# πͺ CryptoBERT Gradio Inference App
|
| 18 |
+
|
| 19 |
+
A clean, modern Gradio interface for **CryptoBERT**, a fine-tuned BERT model for cryptocurrency-related text classification β complete with Hugging Face authentication management, dynamic token updates, and integrated sample dataset previews.
|
| 20 |
+
|
| 21 |
+
---
|
| 22 |
+
|
| 23 |
+
## π¦ Features
|
| 24 |
+
|
| 25 |
+
β
**CryptoBERT Text Classification**
|
| 26 |
+
β
**Gradio UI with Sidebar & Tabs**
|
| 27 |
+
β
**Dynamic Hugging Face Token Authentication**
|
| 28 |
+
β
**Secure Token Management with .env Support**
|
| 29 |
+
β
**Sample Dataset Preview (AG News)**
|
| 30 |
+
β
**Structured, Testable Python Codebase**
|
| 31 |
+
β
**PEP 8 & Security Best Practices**
|
| 32 |
+
β
**Unit Testing Included**
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
## πΈ Demo Preview
|
| 37 |
+
|
| 38 |
+

|
| 39 |
+
|
| 40 |
+
---
|
| 41 |
+
|
| 42 |
+
## π Quickstart
|
| 43 |
+
|
| 44 |
+
### 1οΈβ£ Clone the Repository
|
| 45 |
+
```bash
|
| 46 |
+
git clone https://github.com/your-username/crypto-bert-inference.git
|
| 47 |
+
cd crypto-bert-inference
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### 2οΈβ£ Install Dependencies
|
| 51 |
+
```bash
|
| 52 |
+
pip install -r requirements.txt
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
### 3οΈβ£ Configure Environment Variables
|
| 56 |
+
|
| 57 |
+
Create a `.env` file:
|
| 58 |
+
```bash
|
| 59 |
+
cp .env.example .env
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
Edit `.env`:
|
| 63 |
+
```dotenv
|
| 64 |
+
HUGGINGFACE_TOKEN=your_huggingface_token_here
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
### 4οΈβ£ Launch the App
|
| 68 |
+
```bash
|
| 69 |
+
python app.py
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
The Gradio interface will open in your browser.
|
| 73 |
+
|
| 74 |
+
---
|
| 75 |
+
|
| 76 |
+
## π Usage
|
| 77 |
+
|
| 78 |
+
### π Authenticate with Hugging Face
|
| 79 |
+
- Enter your Hugging Face token in the sidebar
|
| 80 |
+
- Click `Set Token` to authenticate dynamically
|
| 81 |
+
|
| 82 |
+
### π Run Crypto Sentiment Inference
|
| 83 |
+
- Switch to the `CryptoTalk Inference` tab
|
| 84 |
+
- Enter cryptocurrency-related text
|
| 85 |
+
- Click `Predict` to view sentiment predictions
|
| 86 |
+
|
| 87 |
+
### π View Sample Dataset
|
| 88 |
+
- The sidebar displays a preview sample from the `AG News` dataset for demo purposes
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
## ποΈ Project Structure
|
| 93 |
+
|
| 94 |
+
```
|
| 95 |
+
crypto-bert-inference/
|
| 96 |
+
βββ app.py
|
| 97 |
+
βββ pipeline_utils.py
|
| 98 |
+
βββ .env
|
| 99 |
+
βββ requirements.txt
|
| 100 |
+
βββ tests/
|
| 101 |
+
β βββ test_app.py
|
| 102 |
+
βββ README.md
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## π§ͺ Run Unit Tests
|
| 108 |
+
|
| 109 |
+
```bash
|
| 110 |
+
python -m unittest discover tests
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
---
|
| 114 |
+
|
| 115 |
+
## π Dependencies
|
| 116 |
+
|
| 117 |
+
- [transformers](https://github.com/huggingface/transformers)
|
| 118 |
+
- [gradio](https://gradio.app)
|
| 119 |
+
- [datasets](https://huggingface.co/docs/datasets)
|
| 120 |
+
- [python-dotenv](https://github.com/theskumar/python-dotenv)
|
| 121 |
+
- [requests](https://docs.python-requests.org/en/latest/)
|
| 122 |
+
|
| 123 |
+
---
|
| 124 |
+
|
| 125 |
+
## π Documentation
|
| 126 |
+
|
| 127 |
+
- [CryptoBERT Model (kk08/CryptoBERT)](https://huggingface.co/kk08/CryptoBERT)
|
| 128 |
+
- [Gradio Blocks API](https://www.gradio.app/docs/blocks)
|
| 129 |
+
- [Hugging Face Authentication API](https://huggingface.co/docs/hub/security-tokens)
|
| 130 |
+
|
| 131 |
+
---
|
| 132 |
+
|
| 133 |
+
## π‘ Future Enhancements
|
| 134 |
+
|
| 135 |
+
- π³ Dockerized deployment
|
| 136 |
+
- π Inference result charting
|
| 137 |
+
- π Web-hosted demo on Hugging Face Spaces
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
## π‘οΈ Security Considerations
|
| 142 |
+
|
| 143 |
+
- Tokens are stored securely via environment variables
|
| 144 |
+
- No plaintext token persistence or hardcoding
|
| 145 |
+
- Input validation handled by Transformers pipelines
|
| 146 |
+
- Isolated inference processes
|
| 147 |
+
|
| 148 |
+
---
|
| 149 |
+
|
| 150 |
+
## π License
|
| 151 |
+
|
| 152 |
+
MIT Β© [Your Name](https://github.com/your-username)
|
| 153 |
+
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
## π₯οΈ Author
|
| 157 |
+
|
| 158 |
+
**[Your Name]** β *Cybersecurity & AI Developer*
|
| 159 |
+
[GitHub](https://github.com/canstralian) | [LinkedIn](https://www.linkedin.com/in/stephen-de-jager-71b52b29b/)
|
| 160 |
+
|
| 161 |
+
```
|
| 162 |
+
|