Instructions to use aipanjab/digit-recognition with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use aipanjab/digit-recognition with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://aipanjab/digit-recognition") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -79,17 +79,13 @@ python digit-recognition/inference.py my-digit.png
|
|
| 79 |
my-digit.png: ੨ 0.99, ੩ 0.01, ੭ 0.00
|
| 80 |
```
|
| 81 |
|
| 82 |
-
**From Python**
|
| 83 |
|
| 84 |
```python
|
| 85 |
-
import sys
|
| 86 |
-
from huggingface_hub import snapshot_download
|
| 87 |
-
|
| 88 |
-
sys.path.insert(0, snapshot_download("aipanjab/digit-recognition"))
|
| 89 |
from inference import DigitRecognizer
|
| 90 |
|
| 91 |
-
recognizer = DigitRecognizer()
|
| 92 |
-
print(recognizer.predict("my-digit.png"))
|
| 93 |
```
|
| 94 |
|
| 95 |
`predict` takes a file path, an open file or a PIL image, and `top_k` (default 3). A picture with nothing drawn on it
|
|
|
|
| 79 |
my-digit.png: ੨ 0.99, ੩ 0.01, ੭ 0.00
|
| 80 |
```
|
| 81 |
|
| 82 |
+
**From Python**, inside the downloaded folder:
|
| 83 |
|
| 84 |
```python
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
from inference import DigitRecognizer
|
| 86 |
|
| 87 |
+
recognizer = DigitRecognizer() # device="auto": an NVIDIA GPU if onnxruntime-gpu finds one, else the CPU
|
| 88 |
+
print(recognizer.predict("my-digit.png")) # {'੨': 0.99, '੩': 0.01, '੭': 0.0}
|
| 89 |
```
|
| 90 |
|
| 91 |
`predict` takes a file path, an open file or a PIL image, and `top_k` (default 3). A picture with nothing drawn on it
|