Pujan Neupane commited on
Commit
f70e4b3
·
1 Parent(s): d762de0

Updated the MODEL foler i.e the hugging face model downloader

Browse files
Files changed (4) hide show
  1. MODEL/app.py +18 -0
  2. MODEL/readme.md +61 -0
  3. MODEL/requirements.txt +1 -0
  4. README.md +4 -0
MODEL/app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import Repository
3
+
4
+
5
+ def download_repo():
6
+ hf_token = os.getenv("HF_TOKEN")
7
+ if not hf_token:
8
+ raise ValueError("HF_TOKEN not found in environment variables.")
9
+
10
+ repo_id = "can-org/AIModel"
11
+ local_dir = "../Ai-Text-Detector/"
12
+
13
+ repo = Repository(local_dir, clone_from=repo_id, token=hf_token)
14
+ print(f"Repository downloaded to: {local_dir}")
15
+
16
+
17
+ if __name__ == "__main__":
18
+ download_repo()
MODEL/readme.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Hugging Face CLI Tool
2
+
3
+ This CLI tool allows you to **upload** and **download** models from Hugging Face repositories. It requires an **Hugging Face Access Token (`HF_TOKEN`)** for authentication, especially for private repositories.
4
+
5
+ ### Prerequisites
6
+
7
+ 1. **Install Hugging Face Hub**:
8
+
9
+ ```bash
10
+ pip install huggingface_hub
11
+ ```
12
+
13
+ 2. **Get HF_TOKEN**:
14
+ - Log in to [Hugging Face](https://huggingface.co/).
15
+ - Go to **Settings** → **Access Tokens** → **Create a new token** with `read` and `write` permissions.
16
+ - Save the token.
17
+
18
+ ### Usage
19
+
20
+ 1. **Set the Token**:
21
+
22
+ - **Linux/macOS**:
23
+ ```bash
24
+ export HF_TOKEN=your_token_here
25
+ ```
26
+ - **Windows (CMD)**:
27
+ ```bash
28
+ set HF_TOKEN=your_token_here
29
+ ```
30
+
31
+ 2. **Download Model**:
32
+
33
+ ```bash
34
+ python main.py --download --repo-id <repo_name> --save-dir <local_save_path>
35
+ ```
36
+
37
+ 3. **Upload Model**:
38
+ ```bash
39
+ python main.py --upload --repo-id <repo_name> --model-path <local_model_path>
40
+ ```
41
+
42
+ ### Example
43
+
44
+ To download a model:
45
+
46
+ ```bash
47
+ python main.py
48
+ ```
49
+
50
+ ### Authentication
51
+
52
+ Ensure you set `HF_TOKEN` to access private repositories. If not set, the script will raise an error.
53
+ Here’s a clearer and more polished version of that note:
54
+
55
+ ---
56
+
57
+ ### ⚠️ Note
58
+
59
+ **Make sure to run this script from the `HuggingFace` directory to ensure correct path resolution and functionality.**
60
+
61
+ ---
MODEL/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ huggingface_hub
README.md CHANGED
@@ -262,3 +262,7 @@ curl -X POST http://localhost:3000/analyze-text \
262
  -H 'Content-Type: application/json' \
263
  -d '{"text": "This is a test input"}'
264
  ```
 
 
 
 
 
262
  -H 'Content-Type: application/json' \
263
  -d '{"text": "This is a test input"}'
264
  ```
265
+
266
+
267
+ ### MODEL
268
+ - You can download the model from the `/MODEL/app.py` file.