Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EasyOCR Artifact #1616

Merged
merged 10 commits into from
May 13, 2021
Merged

EasyOCR Artifact #1616

merged 10 commits into from
May 13, 2021

Conversation

gregd33
Copy link
Contributor

@gregd33 gregd33 commented May 10, 2021

Description

Same code to use it would be:

@bentoml.artifacts([
    EasyOCRArtifact("chinese_small")
])

and

service = EasyOCR()

lang_list = ['ch_sim', 'en']
recog_network = "zh_sim_g2"

model = easyocr.Reader(lang_list=lang_list, download_enabled=True, recog_network=recog_network )   
service.pack('chinese_small', model, lang_list=lang_list, recog_network= recog_network)

saved_path = service.save()

Artifact for EasyOCR

Motivation and Context

See #1538

How Has This Been Tested?

In progress

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature and improvements (non-breaking change which adds/improves functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Code Refactoring (internal change which is not user facing)
  • Documentation
  • Test, CI, or build

Component(s) if applicable

  • BentoService (service definition, dependency management, API input/output adapters)
  • Model Artifact (model serialization, multi-framework support)
  • Model Server (mico-batching, dockerisation, logging, OpenAPI, instruments)
  • YataiService gRPC server (model registry, cloud deployment automation)
  • YataiService web server (nodejs HTTP server and web UI)
  • Internal (BentoML's own configuration, logging, utility, exception handling)
  • BentoML CLI

Checklist:

To do

  • My code follows the bentoml code style, both ./dev/format.sh and
    ./dev/lint.sh script have passed
    (instructions).
  • My change reduces project test coverage and requires unit tests to be added
  • I have added unit tests covering my code change
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

@pep8speaks
Copy link

pep8speaks commented May 10, 2021

Hello @gregd33, Thanks for updating this PR.

There are currently no PEP 8 issues detected in this PR. Cheers! 🍻

Comment last updated at 2021-05-13 02:46:11 UTC

@gregd33 gregd33 changed the title [IN PROGRESS] Easy OCR [IN PROGRESS] EasyOCR Artifact May 10, 2021
@codecov
Copy link

codecov bot commented May 10, 2021

Codecov Report

Merging #1616 (6d22df3) into master (6f67144) will increase coverage by 0.11%.
The diff coverage is 87.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1616      +/-   ##
==========================================
+ Coverage   65.15%   65.26%   +0.11%     
==========================================
  Files         158      159       +1     
  Lines       11280    11337      +57     
==========================================
+ Hits         7349     7399      +50     
- Misses       3931     3938       +7     
Impacted Files Coverage Δ
bentoml/artifact/__init__.py 0.00% <0.00%> (ø)
bentoml/frameworks/easyocr.py 89.28% <89.28%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6f67144...6d22df3. Read the comment docs.

@gregd33
Copy link
Contributor Author

gregd33 commented May 10, 2021

One thing I'm uncertain about is if this is valid:

def load(self, path, gpu=False):

Since the gpu will be determined on run time essentially (i.e. not when it is packed/saved) I thought it would make sense in load but am unsure how the user would use this arg.

Another question: I'm writing some tests now and need an image to send. Where can I store this image to access it for the test?

@yubozhao

@yubozhao
Copy link
Contributor

One thing I'm uncertain about is if this is valid:

def load(self, path, gpu=False):

Since the gpu will be determined on run time essentially (i.e. not when it is packed/saved) I thought it would make sense in load but am unsure how the user would use this arg.

Right now, it is difficult to modify the load behavior for model during loading BentoService. The current practice for setting additional option is in @artifacts decorator when define bento service. I think that's enough for most use-cases, where people would know ahead of using GPU or not in production.

Another question: I'm writing some tests now and need an image to send. Where can I store this image to access it for the test?

You can store a small test image in the same directory as the test files

@gregd33
Copy link
Contributor Author

gregd33 commented May 11, 2021

@yubozhao thanks. I've removed gpu and added the image. I think I have all the pieces in place now. I'll wait to see what the CI checks say

@gregd33 gregd33 changed the title [IN PROGRESS] EasyOCR Artifact EasyOCR Artifact May 11, 2021
@gregd33
Copy link
Contributor Author

gregd33 commented May 11, 2021

Ready for review

@yubozhao
Copy link
Contributor

yubozhao commented May 12, 2021

@gregd33 It looks great. I think you will need to update the CI configuration and related files to make sure the integration test is running

You will need to update the CI, similar to the changes:

xgboost_integration_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all tags and branches
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.6.10
- name: Install test dependencies
run: ./ci/install_test_deps.sh.cmd
- name: Run tests
run: ./ci/xgboost_integration_tests.sh
- name: Upload test coverage to Codecov
uses: codecov/codecov-action@v1.0.12

You will need to add scripts that install and run the tests. Similar to these files:
https://github.com/bentoml/BentoML/blob/master/ci/xgboost_integration_tests.sh

Make sure to give the bash script correct permissions for running chmod +x

@gregd33
Copy link
Contributor Author

gregd33 commented May 12, 2021

Okay easyocr integration test now enabled and passing

@gregd33
Copy link
Contributor Author

gregd33 commented May 12, 2021

Realized that I omitted gpu completely instead of making it configurable at pack time. I've now fixed that.

@yubozhao
Copy link
Contributor

Realized that I omitted gpu completely instead of making it configurable at pack time. I've now fixed that.

Did you push that change? I can't seem to find it

@gregd33
Copy link
Contributor Author

gregd33 commented May 13, 2021

Thought I did but guess not. Pushed now

@yubozhao yubozhao merged commit 4019bac into bentoml:master May 13, 2021
@yubozhao
Copy link
Contributor

@gregd33 Merged Thank you for contributing!

aarnphm pushed a commit to aarnphm/BentoML that referenced this pull request Jul 29, 2022
* added necessary boilerplate

* initial comit of working artifact

* added tests

* tests now working

* fixed formating issues

* added noqa: E402

* format fix

* enabled integration test

* fixed test image path

* fixed gpu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants