File size: 2,316 Bytes
b4f755d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
## πŸ—οΈ Project Structure

```
β”œβ”€β”€ app.py                   # Main FastAPI app entrypoint
β”œβ”€β”€ config.py                # Configuration loader (.env, settings)
β”œβ”€β”€ features/
β”‚   β”œβ”€β”€ text_classifier/     # English (GPT-2) classifier
β”‚   β”‚   β”œβ”€β”€ controller.py
β”‚   β”‚   β”œβ”€β”€ inferencer.py
β”‚   β”‚   β”œβ”€β”€ model_loader.py
β”‚   β”‚   β”œβ”€β”€ preprocess.py
β”‚   β”‚   └── routes.py
β”‚   └── nepali_text_classifier/ # Nepali (sentencepiece) classifier
β”‚       β”œβ”€β”€ controller.py
β”‚       β”œβ”€β”€ inferencer.py
β”‚       β”œβ”€β”€ model_loader.py
β”‚       β”œβ”€β”€ preprocess.py
β”‚       └── routes.py
β”œβ”€β”€ np_text_model/           # Nepali model artifacts (auto-downloaded)
β”‚   β”œβ”€β”€ classifier/
β”‚   β”‚   └── sentencepiece.bpe.model
β”‚   └── model_95_acc.pth
β”œβ”€β”€ models/                  # English GPT-2 model/tokenizer (auto-downloaded)
β”‚   β”œβ”€β”€ merges.txt
β”‚   β”œβ”€β”€ tokenizer.json
β”‚   └── model_weights.pth
β”œβ”€β”€ Dockerfile               # Container build config
β”œβ”€β”€ Procfile                 # Deployment entrypoint (for PaaS)
β”œβ”€β”€ requirements.txt         # Python dependencies
β”œβ”€β”€ README.md     
β”œβ”€β”€ Docs                     # documents
└── .env                     # Secret token(s), environment config
```
### 🌟 Key Files and Their Roles

- **`app.py`**: Entry point initializing FastAPI app and routes.
- **`Procfile`**: Tells Railway (or similar platforms) how to run the program.
- **`requirements.txt`**: Tracks all Python dependencies for the project.
- **`__init__.py`**: Package initializer for the root module and submodules.
- **`features/text_classifier/`**
  - **`controller.py`**: Handles logic between routes and the model.
  - **`inferencer.py`**: Runs inference and returns predictions as well as file system 
  utilities.
- **`features/NP/`**
  - **`controller.py`**: Handles logic between routes and the model.
  - **`inferencer.py`**: Runs inference and returns predictions as well as file system 
  utilities.
  - **`model_loader.py`**: Loads the ML model and tokenizer.
  - **`preprocess.py`**: Prepares input text for the model.
  - **`routes.py`**: Defines API routes for text classification.



-[Main](../README.md)