Innopolis University DevOps Playground
Skip to content
Snippets Groups Projects
Unverified Commit f131b989 authored by Anton Kudryavtsev's avatar Anton Kudryavtsev
Browse files

feat: extend image plugins

parent 1e189d11
No related branches found
No related tags found
1 merge request!21Feature/extend plugin system image models
......@@ -73,8 +73,8 @@ async def process_image(request: ImageProcessingRequest):
plugin_info.class_name, ImageProcessingFunction, str(filepath)
)
extracted_text = await asyncio.get_running_loop().run_in_executor(
model_response = await asyncio.get_running_loop().run_in_executor(
None, lambda: job.get(blocking=True, preserve=True)
)
return ImageProcessingResponse(text=extracted_text)
return ImageProcessingResponse.parse_obj(model_response.dict())
......@@ -26,8 +26,26 @@ class ImageProcessingRequest(BaseModel):
image_model: str
class IPRPoint(BaseModel):
x: int
y: int
class IPRRectangle(BaseModel):
left_top: IPRPoint
right_top: IPRPoint
left_bottom: IPRPoint
right_bottom: IPRPoint
class IPRTextBox(BaseModel):
text: str
coordinates: IPRRectangle
class ImageProcessingResponse(BaseModel):
text: str
boxes: List[IPRTextBox]
class AudioProcessingRequest(BaseModel):
......
......@@ -4,4 +4,11 @@ from core.plugins.loader import (
load_plugins,
register_plugin,
)
from core.plugins.base import AudioChunk, AudioProcessingResult
from core.plugins.base import (
AudioChunk,
AudioProcessingResult,
Point,
Rectangle,
ImageTextBox,
ImageProcessingResult,
)
......@@ -13,6 +13,28 @@ class AudioProcessingResult(BaseModel):
segments: List[AudioChunk]
class Point(BaseModel):
x: int
y: int
class Rectangle(BaseModel):
left_top: Point
right_top: Point
left_bottom: Point
right_bottom: Point
class ImageTextBox(BaseModel):
text: str
coordinates: Rectangle
class ImageProcessingResult(BaseModel):
text: str
boxes: List[ImageTextBox]
@runtime_checkable
class BasePlugin(Protocol):
"""
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment