Skip to content

Instantly share code, notes, and snippets.

@chck
Last active May 11, 2018 09:00
Show Gist options
  • Save chck/f9ba6699dc392f4a07fdb00efe616a84 to your computer and use it in GitHub Desktop.
Save chck/f9ba6699dc392f4a07fdb00efe616a84 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Try OCR: to extract text from creative\n",
"- [tl;dr](#Conclusion)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pyocr"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"data_dir = '../dataset/understanding_ads/'"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ls: ../dataset/understanding_ads/: No such file or directory\r\n"
]
}
],
"source": [
"!ls $data_dir"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from io import BytesIO\n",
"from PIL import Image, ImageDraw\n",
"from urllib.request import urlopen"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## From Color Image"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment