Last active
November 13, 2022 16:31
-
-
Save ahmedbesbes/34a305f4350344c13a7a0ba3e587cf6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import bentoml | |
import PIL.Image | |
import bentoml | |
from bentoml.io import Image, Text | |
transformers_runner = bentoml.transformers.get("sentiment_model:latest").to_runner() | |
ocr_runner = bentoml.easyocr.get("ocr_model:latest").to_runner() | |
svc = bentoml.Service("sentiment_analysis", runners=[transformers_runner, ocr_runner]) | |
@svc.api(input=Image(),output=Text()) | |
def classify(input: PIL.Image.Image) -> str: | |
ocr_text = ocr_runner.run(input) | |
return transformers_runner.run(ocr_text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment