cosmicshubham commited on
Commit
9d99e38
·
verified ·
1 Parent(s): 9825b78

Upload demo.ipynb with huggingface_hub

Browse files
Files changed (1) hide show
  1. demo.ipynb +65 -0
demo.ipynb ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "metadata": {},
6
+ "source": [
7
+ "# Ancient Manuscript OCR Demo\n",
8
+ "\n",
9
+ "This notebook demonstrates how to use the Ancient Manuscript OCR model."
10
+ ]
11
+ },
12
+ {
13
+ "cell_type": "code",
14
+ "execution_count": null,
15
+ "metadata": {},
16
+ "outputs": [],
17
+ "source": [
18
+ "# Install dependencies\n",
19
+ "!pip install torch torchvision pillow huggingface_hub -q"
20
+ ]
21
+ },
22
+ {
23
+ "cell_type": "code",
24
+ "execution_count": null,
25
+ "metadata": {},
26
+ "outputs": [],
27
+ "source": [
28
+ "# Download model from Hugging Face\n",
29
+ "from huggingface_hub import hf_hub_download\n",
30
+ "\n",
31
+ "model_path = hf_hub_download(\n",
32
+ " repo_id='cosmicshubham/ancient-manuscript-ocr',\n",
33
+ " filename='best_model.pth'\n",
34
+ ")\n",
35
+ "\n",
36
+ "print(f'Model downloaded to: {model_path}')"
37
+ ]
38
+ },
39
+ {
40
+ "cell_type": "code",
41
+ "execution_count": null,
42
+ "metadata": {},
43
+ "outputs": [],
44
+ "source": [
45
+ "# Load and use the model\n",
46
+ "from inference import ManuscriptOCR\n",
47
+ "\n",
48
+ "ocr = ManuscriptOCR(model_path=model_path)\n",
49
+ "\n",
50
+ "# Predict on your image\n",
51
+ "text = ocr.predict('path/to/your/manuscript.jpg')\n",
52
+ "print(f'Recognized Text: {text}')"
53
+ ]
54
+ }
55
+ ],
56
+ "metadata": {
57
+ "kernelspec": {
58
+ "display_name": "Python 3",
59
+ "language": "python",
60
+ "name": "python3"
61
+ }
62
+ },
63
+ "nbformat": 4,
64
+ "nbformat_minor": 4
65
+ }