|
31 | 31 | }, |
32 | 32 | "outputs": [], |
33 | 33 | "source": [ |
34 | | - "!sudo apt install tesseract-ocr\n", |
| 34 | + "import os\n", |
| 35 | + "if (os.name) != \"nt\":\n", |
| 36 | + " print(\"Not using Windows\")\n", |
| 37 | + " !sudo apt install tesseract-ocr\n", |
35 | 38 | "!pip install pytesseract" |
36 | 39 | ] |
37 | 40 | }, |
|
50 | 53 | "4. Set the tesseract path in the script before calling image_to_string." |
51 | 54 | ] |
52 | 55 | }, |
53 | | - { |
54 | | - "cell_type": "code", |
55 | | - "execution_count": 2, |
56 | | - "metadata": {}, |
57 | | - "outputs": [], |
58 | | - "source": [ |
59 | | - "# ONLY FOR WINDOWS USERS\n", |
60 | | - "# Setting the tesseract path in the script before calling image_to_string.\n", |
61 | | - "import pytesseract\n", |
62 | | - "pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe' " |
63 | | - ] |
64 | | - }, |
65 | 56 | { |
66 | 57 | "cell_type": "markdown", |
67 | 58 | "metadata": {}, |
|
82 | 73 | "#making the necessary imports\n", |
83 | 74 | "import pytesseract\n", |
84 | 75 | "from pytesseract import image_to_string\n", |
85 | | - "from PIL import Image" |
| 76 | + "from PIL import Image\n", |
| 77 | + "\n", |
| 78 | + "# ONLY FOR WINDOWS USERS\n", |
| 79 | + "# Setting the tesseract path in the script before calling image_to_string.\n", |
| 80 | + "if (os.name) == \"nt\":\n", |
| 81 | + " pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'" |
86 | 82 | ] |
87 | 83 | }, |
88 | 84 | { |
|
120 | 116 | }, |
121 | 117 | "outputs": [], |
122 | 118 | "source": [ |
123 | | - "#uploading an image into colab\n", |
124 | | - "# from google.colab import files\n", |
125 | | - "# uploaded = files.upload()" |
| 119 | + "# uploading an image into colab\n", |
| 120 | + "try:\n", |
| 121 | + " from google.colab import files\n", |
| 122 | + " uploaded = files.upload()\n", |
| 123 | + "except ModuleNotFoundError:\n", |
| 124 | + " print(\"Not using colab\")" |
126 | 125 | ] |
127 | 126 | }, |
128 | 127 | { |
|
216 | 215 | "name": "python", |
217 | 216 | "nbconvert_exporter": "python", |
218 | 217 | "pygments_lexer": "ipython3", |
219 | | - "version": "3.7.4" |
| 218 | + "version": "3.6.8" |
| 219 | + }, |
| 220 | + "varInspector": { |
| 221 | + "cols": { |
| 222 | + "lenName": 16, |
| 223 | + "lenType": 16, |
| 224 | + "lenVar": 40 |
| 225 | + }, |
| 226 | + "kernels_config": { |
| 227 | + "python": { |
| 228 | + "delete_cmd_postfix": "", |
| 229 | + "delete_cmd_prefix": "del ", |
| 230 | + "library": "var_list.py", |
| 231 | + "varRefreshCmd": "print(var_dic_list())" |
| 232 | + }, |
| 233 | + "r": { |
| 234 | + "delete_cmd_postfix": ") ", |
| 235 | + "delete_cmd_prefix": "rm(", |
| 236 | + "library": "var_list.r", |
| 237 | + "varRefreshCmd": "cat(var_dic_list()) " |
| 238 | + } |
| 239 | + }, |
| 240 | + "types_to_exclude": [ |
| 241 | + "module", |
| 242 | + "function", |
| 243 | + "builtin_function_or_method", |
| 244 | + "instance", |
| 245 | + "_Feature" |
| 246 | + ], |
| 247 | + "window_display": false |
220 | 248 | } |
221 | 249 | }, |
222 | 250 | "nbformat": 4, |
|
0 commit comments