Skip to content

Commit ba06e29

Browse files
Added if conditions to determine os and run instructions
1 parent 34aa7cf commit ba06e29

File tree

2 files changed

+82
-24
lines changed

2 files changed

+82
-24
lines changed

Ch2/03_Extracting_text_from_images_tesseract.ipynb

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
},
3232
"outputs": [],
3333
"source": [
34-
"!sudo apt install tesseract-ocr\n",
35-
"!pip install pytesseract"
34+
"if (os.name) != \"nt\":\n",
35+
" print(\"Not using Windows\")\n",
36+
" !sudo apt install tesseract-ocr\n",
37+
" !pip install pytesseract"
3638
]
3739
},
3840
{
@@ -50,18 +52,6 @@
5052
"4. Set the tesseract path in the script before calling image_to_string."
5153
]
5254
},
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-
},
6555
{
6656
"cell_type": "markdown",
6757
"metadata": {},
@@ -82,7 +72,12 @@
8272
"#making the necessary imports\n",
8373
"import pytesseract\n",
8474
"from pytesseract import image_to_string\n",
85-
"from PIL import Image"
75+
"from PIL import Image\n",
76+
"\n",
77+
"# ONLY FOR WINDOWS USERS\n",
78+
"# Setting the tesseract path in the script before calling image_to_string.\n",
79+
"if (os.name) == \"nt\":\n",
80+
" pytesseract.pytesseract.tesseract_cmd = r'C:\\Program Files\\Tesseract-OCR\\tesseract.exe'"
8681
]
8782
},
8883
{
@@ -120,9 +115,12 @@
120115
},
121116
"outputs": [],
122117
"source": [
123-
"#uploading an image into colab\n",
124-
"# from google.colab import files\n",
125-
"# uploaded = files.upload()"
118+
"# uploading an image into colab\n",
119+
"try:\n",
120+
" from google.colab import files\n",
121+
" uploaded = files.upload()\n",
122+
"except ModuleNotFoundError:\n",
123+
" print(\"Not using colab\")"
126124
]
127125
},
128126
{
@@ -216,7 +214,36 @@
216214
"name": "python",
217215
"nbconvert_exporter": "python",
218216
"pygments_lexer": "ipython3",
219-
"version": "3.7.4"
217+
"version": "3.6.8"
218+
},
219+
"varInspector": {
220+
"cols": {
221+
"lenName": 16,
222+
"lenType": 16,
223+
"lenVar": 40
224+
},
225+
"kernels_config": {
226+
"python": {
227+
"delete_cmd_postfix": "",
228+
"delete_cmd_prefix": "del ",
229+
"library": "var_list.py",
230+
"varRefreshCmd": "print(var_dic_list())"
231+
},
232+
"r": {
233+
"delete_cmd_postfix": ") ",
234+
"delete_cmd_prefix": "rm(",
235+
"library": "var_list.r",
236+
"varRefreshCmd": "cat(var_dic_list()) "
237+
}
238+
},
239+
"types_to_exclude": [
240+
"module",
241+
"function",
242+
"builtin_function_or_method",
243+
"instance",
244+
"_Feature"
245+
],
246+
"window_display": false
220247
}
221248
},
222249
"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)