Ali0044 commited on
Commit
0901703
·
verified ·
1 Parent(s): 15e3cdb

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +11 -6
README.md CHANGED
@@ -12,11 +12,11 @@ tags:
12
 
13
  # Qalam-Net (قلم-نت): Advanced Arabic OCR (v2 Portable)
14
 
15
- Qalam-Net is a high-performance, cross-backend Optical Character Recognition (OCR) model for Arabic. This version (**v2**) has been patched for maximum portability across Keras versions and optimized for inference.
16
 
17
- ## 🚀 Quick Start (Clean Inference)
18
 
19
- Qalam-Net v2 no longer requires custom layers or complex setup during inference.
20
 
21
  ### 1. Installation
22
  ```bash
@@ -31,12 +31,17 @@ os.environ["KERAS_BACKEND"] = "jax" # Options: "jax", "tensorflow", "torch"
31
  import keras
32
  import numpy as np
33
  import cv2
 
34
 
35
  class QalamNet:
36
  def __init__(self, repo_id="Ali0044/Qalam-Net"):
37
- # Load the portable model directly from Hugging Face
38
- # No 'custom_objects' or 'CTCLayer' required!
39
- self.model = keras.saving.load_model(f"hf://{repo_id}")
 
 
 
 
40
 
41
  # Standard Arabic Vocabulary
42
  self.vocab = [' ', '!', '"', '#', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '=', '?', '[', ']', 'ء', 'آ', 'أ', 'ؤ', 'إ', 'ئ', 'ا', 'ب', 'ة', 'ت', 'ث', 'ج', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ـ', 'ف', 'ق', 'ك', 'ل', 'م', 'ن', 'ه', 'و', 'ى', 'ي', 'ً', 'ٌ', 'ٍ', 'َ', 'ُ', 'ِ', 'ّ', 'ْ', '٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']
 
12
 
13
  # Qalam-Net (قلم-نت): Advanced Arabic OCR (v2 Portable)
14
 
15
+ Qalam-Net is a high-performance, cross-backend Optical Character Recognition (OCR) model for Arabic. Built on **Keras 3**, it supports **JAX**, **PyTorch**, and **TensorFlow** backends.
16
 
17
+ ## 🚀 Quick Start (Robust Usage)
18
 
19
+ For maximum reliability across all environments, use the `huggingface_hub` downloader.
20
 
21
  ### 1. Installation
22
  ```bash
 
31
  import keras
32
  import numpy as np
33
  import cv2
34
+ from huggingface_hub import hf_hub_download
35
 
36
  class QalamNet:
37
  def __init__(self, repo_id="Ali0044/Qalam-Net"):
38
+ # 1. Download the portable model file from the Hub
39
+ print(f"Downloading model from {repo_id}...")
40
+ model_path = hf_hub_download(repo_id=repo_id, filename="model.keras")
41
+
42
+ # 2. Load the model (Self-contained v2 requires no custom_objects)
43
+ self.model = keras.saving.load_model(model_path)
44
+ print("Model loaded successfully!")
45
 
46
  # Standard Arabic Vocabulary
47
  self.vocab = [' ', '!', '"', '#', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '=', '?', '[', ']', 'ء', 'آ', 'أ', 'ؤ', 'إ', 'ئ', 'ا', 'ب', 'ة', 'ت', 'ث', 'ج', 'ح', 'خ', 'د', 'ذ', 'ر', 'ز', 'س', 'ش', 'ص', 'ض', 'ط', 'ظ', 'ع', 'غ', 'ـ', 'ف', 'ق', 'ك', 'ل', 'م', 'ن', 'ه', 'و', 'ى', 'ي', 'ً', 'ٌ', 'ٍ', 'َ', 'ُ', 'ِ', 'ّ', 'ْ', '٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']