• This repository has been archived on 02/Dec/2022
  • Stars
    star
    252
  • Rank 161,312 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Packaged, Pytorch-based, easy to use, cross-platform version of the CRAFT text detector

CRAFT: Character-Region Awareness For Text detection

downloads downloads fcakyon twitter
Build status PyPI version License: MIT

Packaged, Pytorch-based, easy to use, cross-platform version of the CRAFT text detector | Paper |

Overview

PyTorch implementation for CRAFT text detector that effectively detect text area by exploring each character region and affinity between characters. The bounding box of texts are obtained by simply finding minimum bounding rectangles on binary map after thresholding character region and affinity scores.

teaser

Getting started

Installation

  • Install using pip:
pip install craft-text-detector

Basic Usage

# import Craft class
from craft_text_detector import Craft

# set image path and export folder directory
image = 'figures/idcard.png' # can be filepath, PIL image or numpy array
output_dir = 'outputs/'

# create a craft instance
craft = Craft(output_dir=output_dir, crop_type="poly", cuda=False)

# apply craft text detection and export detected regions to output directory
prediction_result = craft.detect_text(image)

# unload models from ram/gpu
craft.unload_craftnet_model()
craft.unload_refinenet_model()

Advanced Usage

# import craft functions
from craft_text_detector import (
    read_image,
    load_craftnet_model,
    load_refinenet_model,
    get_prediction,
    export_detected_regions,
    export_extra_results,
    empty_cuda_cache
)

# set image path and export folder directory
image = 'figures/idcard.png' # can be filepath, PIL image or numpy array
output_dir = 'outputs/'

# read image
image = read_image(image)

# load models
refine_net = load_refinenet_model(cuda=True)
craft_net = load_craftnet_model(cuda=True)

# perform prediction
prediction_result = get_prediction(
    image=image,
    craft_net=craft_net,
    refine_net=refine_net,
    text_threshold=0.7,
    link_threshold=0.4,
    low_text=0.4,
    cuda=True,
    long_size=1280
)

# export detected text regions
exported_file_paths = export_detected_regions(
    image=image,
    regions=prediction_result["boxes"],
    output_dir=output_dir,
    rectify=True
)

# export heatmap, detection points, box visualization
export_extra_results(
    image=image,
    regions=prediction_result["boxes"],
    heatmaps=prediction_result["heatmaps"],
    output_dir=output_dir
)

# unload models from gpu
empty_cuda_cache()

More Repositories

1

content-moderation-deep-learning

Deep learning based content moderation from text, audio, video & image input modalities.
302
star
2

yolov5-pip

Packaged version of ultralytics/yolov5 + many extra features
Python
291
star
3

streamlit-image-comparison

Image comparison slider component for Streamlit
Python
219
star
4

small-object-detection-benchmark

icip2022 paper: sahi benchmark on visdrone and xview datasets using fcos, vfnet and tood detectors
Python
157
star
5

video-transformers

Easiest way of fine-tuning HuggingFace video classification models
Python
131
star
6

pywhisper

openai/whisper + extra features
Python
89
star
7

balanced-loss

Easy to use class balanced cross entropy and focal loss implementation for Pytorch
Python
87
star
8

midv500

Download and convert MIDV-500 annotations to COCO instance segmentation format
Python
83
star
9

ultralyticsplus

Huggingface utilities for Ultralytics/YOLOv8
Python
77
star
10

flask-redis-docker

A minimal template for dockerized flask app with redis task queue
Python
58
star
11

instafake-dataset

Dataset for Intagram Fake and Automated Account Detection
Python
49
star
12

face-recognition-app-tutorial

A face recognition web app powered by Facenet model using Flask, OpenCV, Heroku
HTML
35
star
13

mmdetection-object-tracker

A lightweight script for performing Kalman filter based object tracking using MMDetection models.
Python
22
star
14

augmented-maskrcnn

Object detection and instance segmentation on MaskRCNN with torchvision, albumentations, tensorboard and cocoapi. Supports custom coco datasets with positive/negative samples.
Python
19
star
15

confplot

Confusion Matrix in Python: Plot a pretty confusion matrix (like Matlab) in python using seaborn and matplotlib
Python
11
star
16

face-detection-app-tutorial

A face detection web app powered by SSD face detecctor using Flask, OpenCV, Heroku
Jupyter Notebook
7
star
17

ieee-fraud-detection

IEEE Fraud Detection with XGBoost and CatBoost
Jupyter Notebook
5
star
18

yolov5-to-supervisely

Use your yolov5 predictions as supervisely annotations
Python
4
star
19

cifar100-resnet

ResNet Implementation for CIFAR100 in Pytorch
Jupyter Notebook
4
star
20

turkish-qa-datasets

creating this repo to host some turkish nlp datasets
3
star
21

earth2-scraper

Up-to-date earth2.io data
Python
3
star
22

musicalpy

Easiest way of combining a music and a video
Python
2
star
23

insta-assist

Personal Instagram Tools
Python
2
star
24

fcakyon

2
star
25

deprem-uydu-bina-tespiti

Instance segmentation ve change detection ile uydu goruntusunden bina tespiti
Python
2
star
26

gpt2-shakespeare

A tutorial on GPT2 language model training with texts from Shakespeare
Jupyter Notebook
1
star
27

glassdoor-review-textgenrnn

Train char-rnn with Glassdoor reviews and generate sentences
Python
1
star
28

DiyarMobileFood

C#
1
star
29

public-files

personal repo for hosting large files
1
star