Unanswered
And One More Question. How Can I Get Loaded Model In Preporcess Class In Clearml Serving?
AgitatedDove14 My model has method generate. i would like to call it. How can i get loaded automaticly model from Preprocess object. Preprocess file
` from typing import Any, Callable, Optional
from transformers import TrOCRProcessor
import numpy as np
Notice Preprocess class Must be named "Preprocess"
class Preprocess(object):
def __init__(self):
self.processor = TrOCRProcessor.from_pretrained("microsoft/trocr-small-printed")
def preprocess(self, body: dict, state: dict, collect_custom_statistics_fn=None) -> Any:
return self.processor.batch_decode(np.array(body.get("image")))
def process(
self,
data: Any,
state: dict,
collect_custom_statistics_fn: Optional[Callable[[dict], None]],
) -> Any:
model = #get model
data = model.generate(data.pixel_values)
return data
def postprocess(self, data: Any, state: dict, collect_custom_statistics_fn=None) -> dict:
return dict(predict=data.tolist()) `I trained model and log it to ClearML Server. I try to add it to ClearML Serving, but it call ` forward ` method by default
186 Views
0
Answers
2 years ago
one year ago