Skip to content

Commit

Permalink
Fixed noteboks
Browse files Browse the repository at this point in the history
  • Loading branch information
mykolamelnykml committed Jul 13, 2020
1 parent f9f7b3e commit 6cbc750
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 63 deletions.
4 changes: 2 additions & 2 deletions jupyter/SparkOCRGreyBackground.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
"remove_objects.setMaxSizeObject(1000)\n",
"remove_objects.setMinSizeObject(None)\n",
"\n",
"# Run tesseract OCR for each region\n",
"# Run OCR for each region\n",
"ocr_corrected = ImageToText()\n",
"ocr_corrected.setInputCol(\"corrected_image\")\n",
"ocr_corrected.setOutputCol(\"text_corrected\")\n",
Expand Down Expand Up @@ -322,7 +322,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Results of simple TesseractOCR"
"## Results of simple OCR"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions jupyter/SparkOCRS3AccesExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@
"binary_to_image = BinaryToImage()\n",
"binary_to_image.setOutputCol(\"image\")\n",
"\n",
"# Run tesseract OCR for each region\n",
"# Run OCR for each region\n",
"ocr = ImageToText()\n",
"ocr.setInputCol(\"image\")\n",
"ocr.setOutputCol(\"text\")\n",
Expand Down Expand Up @@ -904,4 +904,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
5 changes: 1 addition & 4 deletions jupyter/SparkOCRremoveBackgroundNoise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,10 @@
"remove_objects.setOutputCol(\"corrected_image\")\n",
"remove_objects.setMinSizeFont(30)\n",
"\n",
"# Run tesseract OCR for each region\n",
"# Run OCR for each region\n",
"ocr = ImageToText()\n",
"ocr.setInputCol(\"corrected_image\")\n",
"ocr.setOutputCol(\"text\")\n",
"# Path to the tessdata related to the OS and version\n",
"# ocr.setTessdata(\"/usr/local/Cellar/tesseract-lang/4.0.0/share/tessdata\")\n",
"# ocr.setLanguage(\"fra\")\n",
"ocr.setConfidenceThreshold(75)\n",
"ocr.setPageSegMode(PageSegmentationMode.SINGLE_BLOCK)\n",
"ocr.setIgnoreResolution(False)\n",
Expand Down
2 changes: 1 addition & 1 deletion jupyter/SparkOCRremoveRackgroundNoiseAndDrawRegions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
"ocr_corrected.setPositionsCol(\"corrected_positions\")\n",
"ocr_corrected.setConfidenceThreshold(65)\n",
"\n",
"# Run tesseract OCR for original image\n",
"# Run OCR for original image\n",
"ocr = ImageToText()\n",
"ocr.setInputCol(\"image\")\n",
"ocr.setOutputCol(\"text\")\n",
Expand Down
63 changes: 20 additions & 43 deletions jupyter/SparkOcrDicomDeIdentification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,6 @@
" height: 841\n",
" mode: 10\n"
]
<<<<<<< HEAD
},
{
"data": {
Expand Down Expand Up @@ -1267,17 +1266,15 @@
]
},
{
"cell_type": "code",
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"source": [
"## Run pipeline and store result"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "code",
Expand Down Expand Up @@ -1313,63 +1310,43 @@
" print(f\"Storing to {file_name}\")\n",
" with open(file_name, \"wb\") as file:\n",
" file.write(r.dicom)"
=======
}
],
"source": [
"de_df = spark.read.format(\"binaryFile\").load(\"././data/dicom/deidentified/*.DCM\")\n",
"de_dicom_df = dicom_to_image.transform(de_df)\n",
"for r in de_dicom_df.select(\"image_raw\",\"metadata\").collect():\n",
" display_image(r.image_raw)\n",
" print(r.metadata)"
>>>>>>> a867e7901abcf88a8c02f8df9f4d011522023e9f
]
},
{
"cell_type": "markdown",
<<<<<<< HEAD
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"source": [
"## Display Deidentified Image and Deidentified metadata"
=======
"metadata": {},
"source": [
"## Remove results"
>>>>>>> a867e7901abcf88a8c02f8df9f4d011522023e9f
"## Display Deidentified Image and Deidentified metadata"
]
},
{
"cell_type": "code",
<<<<<<< HEAD
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%% \n"
=======
"execution_count": 15,
"metadata": {
"pycharm": {
"name": "#%%\n"
>>>>>>> a867e7901abcf88a8c02f8df9f4d011522023e9f
}
},
"metadata": {},
"outputs": [],
"source": [
<<<<<<< HEAD
"dicom_gen_df = spark.read.format(\"binaryFile\").load(\"././data/dicom/deidentified/*.dcm\")\n",
"de_dicom_gen_df = dicom_to_image.transform(dicom_gen_df)\n",
"for r in de_dicom_gen_df.select(\"image_raw\",\"metadata\").collect():\n",
" \n",
" print(r.metadata)\n",
" display_image(r.image_raw)"
=======
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Remove reults"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%bash\n",
"rm -r -f ././data/dicom/deidentified"
>>>>>>> a867e7901abcf88a8c02f8df9f4d011522023e9f
]
}
],
Expand All @@ -1394,4 +1371,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
6 changes: 3 additions & 3 deletions jupyter/SparkOcrHttpSource.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
" pdf_to_image.setInputCol(\"content\")\n",
" pdf_to_image.setOutputCol(\"image\")\n",
"\n",
" # Run tesseract OCR\n",
" # Run OCR\n",
" ocr = ImageToText()\n",
" ocr.setInputCol(\"image\")\n",
" ocr.setOutputCol(\"text\")\n",
Expand Down Expand Up @@ -601,9 +601,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}
4 changes: 2 additions & 2 deletions jupyter/SparkOcrSimpleExample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
" pdf_to_image.setInputCol(\"content\")\n",
" pdf_to_image.setOutputCol(\"image\")\n",
"\n",
" # Run tesseract OCR\n",
" # Run OCR\n",
" ocr = ImageToText()\n",
" ocr.setInputCol(\"image\")\n",
" ocr.setOutputCol(\"text\")\n",
Expand Down Expand Up @@ -543,4 +543,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
6 changes: 3 additions & 3 deletions jupyter/SparkOcrStreamingPDF.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"pdf_to_image = PdfToImage()\n",
"pdf_to_image.setOutputCol(\"image\")\n",
"\n",
"# Run tesseract OCR for each region\n",
"# Run OCR for each region\n",
"ocr = ImageToText()\n",
"ocr.setInputCol(\"image\")\n",
"ocr.setOutputCol(\"text\")\n",
Expand Down Expand Up @@ -484,9 +484,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}
6 changes: 3 additions & 3 deletions jupyter/SparkOcrWithSkewCorrection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
" skew_corrector.setOutputCol(\"corrected_image\")\n",
" skew_corrector.setAutomaticSkewCorrection(skew_correction)\n",
"\n",
" # Run tesseract OCR\n",
" # Run OCR\n",
" ocr = ImageToText()\n",
" ocr.setInputCol(\"corrected_image\")\n",
" ocr.setOutputCol(\"text\")\n",
Expand Down Expand Up @@ -523,9 +523,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
}

0 comments on commit 6cbc750

Please sign in to comment.