<jupyter_start><jupyter_text>Scene Text Detection with EASTThis notebook uses an open source implementation of the paper [EAST: An Efficient and Accurate Scene Text Detector](https://arxiv.org/abs/1704.03155) to detect scene text on a given image.For other deep-learning Colab notebooks, visit [tugstugi/dl-colab-notebooks](https://github.com/tugstugi/dl-colab-notebooks). Install argman/EAST Install the open source project [argman/EAST](https://github.com/argman/EAST.git):<jupyter_code>import os
from os.path import exists, join, basename, splitext

git_repo_url = 'https://github.com/argman/EAST.git'
project_name = splitext(basename(git_repo_url))[0]
if not exists(project_name):
  # clone and install
  !git clone -q $git_repo_url
  #!cd $project_name && pip install -q -r requirements.txt
  
import sys
sys.path.append(project_name)
import time
import matplotlib
import matplotlib.pylab as plt
plt.rcParams["axes.grid"] = False<jupyter_output><empty_output><jupyter_text>Download pretrained model<jupyter_code>def download_from_google_drive(file_id, file_name):
  # download a file from the Google Drive link
  !rm -f ./cookie
  !curl -c ./cookie -s -L "https://drive.google.com/uc?export=download&id=$file_id" > /dev/null
  confirm_text = !awk '/download/ {print $NF}' ./cookie
  confirm_text = confirm_text[0]
  !curl -Lb ./cookie "https://drive.google.com/uc?export=download&confirm=$confirm_text&id=$file_id" -o $file_name
  

pretrained_model = 'east_icdar2015_resnet_v1_50_rbox'
if not exists(pretrained_model):
  # download the pretrained model
  pretrained_model_file_name = 'east_icdar2015_resnet_v1_50_rbox.zip'
  download_from_google_drive('0B3APw5BZJ67ETHNPaU9xUkVoV0U', pretrained_model_file_name)
  !unzip $pretrained_model_file_name<jupyter_output><empty_output><jupyter_text>Detect scene text on a test imageFirst, dowload a test image from internet:<jupyter_code>IMAGE_URL = 'https://raw.githubusercontent.com/tugstugi/dl-colab-notebooks/master/resources/billboard.jpg'


image_file_name = basename(IMAGE_URL)
download_dir = '/content/images'
!mkdir -p $download_dir && rm -rf $download_dir/*
!wget -q -P $download_dir $IMAGE_URL
  

plt.imshow(matplotlib.image.imread(join(download_dir, image_file_name)))<jupyter_output><empty_output><jupyter_text>Run EAST on the above test image:<jupyter_code>!mkdir -p output
!cd $project_name && python eval.py --test_data_path=$download_dir --gpu_list=0 --checkpoint_path=../$pretrained_model/ --output_dir=..<jupyter_output><empty_output><jupyter_text>Now, visualize the result:<jupyter_code>plt.figure(figsize=(20, 26))
plt.imshow(matplotlib.image.imread(image_file_name))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1176911544227886, 'fraction_numerical': 0.013868065967016492, 'mean_word_length': 6.4345403899721445, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '401830', 'license': 'MIT', 'n_tokens_mistral': 993, 'n_tokens_neox': 959, 'n_words': 188, 'path': 'Deep-Learning-Notebooks/notebooks/EAST.ipynb', 'repo_name': 'deepraj1729/Resources-and-Guides', 'size': '2668'}