Skip to content

Instantly share code, notes, and snippets.

@ahmedbesbes
Last active November 13, 2022 16:31
Show Gist options
  • Save ahmedbesbes/34a305f4350344c13a7a0ba3e587cf6b to your computer and use it in GitHub Desktop.
Save ahmedbesbes/34a305f4350344c13a7a0ba3e587cf6b to your computer and use it in GitHub Desktop.
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