Skip to content

Commit aa918b2

Browse files
2 parents e3e9de8 + 33d35d6 commit aa918b2

File tree

2 files changed

+82
-23
lines changed

2 files changed

+82
-23
lines changed

Ch2/03_Extracting_text_from_images_tesseract.ipynb

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
},
3232
"outputs": [],
3333
"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",
3538
"!pip install pytesseract"
3639
]
3740
},
@@ -50,18 +53,6 @@
5053
"4. Set the tesseract path in the script before calling image_to_string."
5154
]
5255
},
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-
},
6556
{
6657
"cell_type": "markdown",
6758
"metadata": {},
@@ -82,7 +73,12 @@
8273
"#making the necessary imports\n",
8374
"import pytesseract\n",
8475
"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'"
8682
]
8783
},
8884
{
@@ -120,9 +116,12 @@
120116
},
121117
"outputs": [],
122118
"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\")"
126125
]
127126
},
128127
{
@@ -216,7 +215,36 @@
216215
"name": "python",
217216
"nbconvert_exporter": "python",
218217
"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
220248
}
221249
},
222250
"nbformat": 4,

Ch3/09_Visualizing_Embeddings_Using_TSNE.ipynb

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@
4141
},
4242
"outputs": [],
4343
"source": [
44-
"#upload the \"word2vec.bin\" file in form the repository which can be found in the same folder as this notebook.\n",
45-
"\n",
4644
"# FOR GOOGLE COLAB USERS\n",
47-
"# from google.colab import files\n",
48-
"# uploaded = files.upload()"
45+
"# upload the \"word2vec.bin\" file in form the repository which can be found in the same folder as this notebook.\n",
46+
"try:\n",
47+
" from google.colab import files\n",
48+
" uploaded = files.upload()\n",
49+
"except ModuleNotFoundError:\n",
50+
" print(\"Not using colab\")"
4951
]
5052
},
5153
{
@@ -393,7 +395,36 @@
393395
"name": "python",
394396
"nbconvert_exporter": "python",
395397
"pygments_lexer": "ipython3",
396-
"version": "3.7.0"
398+
"version": "3.6.8"
399+
},
400+
"varInspector": {
401+
"cols": {
402+
"lenName": 16,
403+
"lenType": 16,
404+
"lenVar": 40
405+
},
406+
"kernels_config": {
407+
"python": {
408+
"delete_cmd_postfix": "",
409+
"delete_cmd_prefix": "del ",
410+
"library": "var_list.py",
411+
"varRefreshCmd": "print(var_dic_list())"
412+
},
413+
"r": {
414+
"delete_cmd_postfix": ") ",
415+
"delete_cmd_prefix": "rm(",
416+
"library": "var_list.r",
417+
"varRefreshCmd": "cat(var_dic_list()) "
418+
}
419+
},
420+
"types_to_exclude": [
421+
"module",
422+
"function",
423+
"builtin_function_or_method",
424+
"instance",
425+
"_Feature"
426+
],
427+
"window_display": false
397428
}
398429
},
399430
"nbformat": 4,

0 commit comments

Comments
 (0)