Instructions to use shailgsits/pan-card-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Keras
How to use shailgsits/pan-card-classifier with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://shailgsits/pan-card-classifier") - Notebooks
- Google Colab
- Kaggle
| import time | |
| from fastapi import FastAPI | |
| from fastapi import UploadFile | |
| from fastapi import File | |
| from fastapi import HTTPException | |
| from PIL import Image | |
| from api.predictor import predict | |
| app = FastAPI( | |
| title="PAN Card Classification API", | |
| version="1.0" | |
| ) | |
| def root(): | |
| return { | |
| "message": "PAN Card Classifier Running" | |
| } | |
| def health(): | |
| return { | |
| "status": "OK" | |
| } | |
| async def predict_pan( | |
| file: UploadFile = File(...) | |
| ): | |
| if file.content_type not in [ | |
| "image/jpeg", | |
| "image/png", | |
| "image/jpg" | |
| ]: | |
| raise HTTPException( | |
| status_code=400, | |
| detail="Only JPG and PNG images are allowed." | |
| ) | |
| start = time.perf_counter() | |
| image = Image.open(file.file) | |
| result = predict(image) | |
| end = time.perf_counter() | |
| return { | |
| "success": True, | |
| "prediction": result, | |
| "model": "MobileNetV2", | |
| "processing_time_ms": round( | |
| (end - start) * 1000, | |
| 2, | |
| ), | |
| } |