mwauranjorogekelvin commited on
Commit
833fa59
·
verified ·
1 Parent(s): 8c4821f

Update download_model.py

Browse files

Update requirements for ONNX

Files changed (1) hide show
  1. download_model.py +27 -11
download_model.py CHANGED
@@ -1,17 +1,33 @@
1
- from transformers import VisionEncoderDecoderModel, TrOCRProcessor
 
2
  import os
3
 
4
- MODEL_ID = 'anuashok/ocr-captcha-v3'
5
- SAVE_PATH = './model'
6
 
7
- print(f"Downloading {MODEL_ID}...")
8
- os.makedirs(SAVE_PATH, exist_ok=True)
 
 
 
9
 
10
- processor = TrOCRProcessor.from_pretrained(MODEL_ID)
11
- model = VisionEncoderDecoderModel.from_pretrained(MODEL_ID)
 
12
 
13
- print("Saving to ./model...")
14
- processor.save_pretrained(SAVE_PATH)
15
- model.save_pretrained(SAVE_PATH)
16
 
17
- print("✅ Model saved successfully")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import hf_hub_download
2
+ import shutil
3
  import os
4
 
5
+ print("Downloading ONNX model from toandev/OCR-for-Captcha...")
6
+ os.makedirs("./model", exist_ok=True)
7
 
8
+ model_path = hf_hub_download(
9
+ repo_id="toandev/OCR-for-Captcha",
10
+ filename="model.onnx",
11
+ repo_type="space"
12
+ )
13
 
14
+ shutil.copy(model_path, "./model/model.onnx")
15
+ print("✅ ONNX model saved to ./model/model.onnx")
16
+ ```
17
 
18
+ Commit message: `"Download ONNX model at build time"`
 
 
19
 
20
+ ---
21
+
22
+ ## File 4 of 6 — `requirements.txt`
23
+
24
+ Files tab → click `requirements.txt` → ✏️ edit → replace everything:
25
+ ```
26
+ fastapi
27
+ uvicorn
28
+ torch
29
+ torchvision
30
+ onnx
31
+ onnxruntime
32
+ Pillow
33
+ huggingface_hub