INNER CODE UNIT · Python

get_input_type

aniketmaurya/chitra · chitra/serve/app.py:64

    def get_input_type(self, **kwargs):
        label = kwargs.get("label")
        if self.api_type in (const.IMAGE_CLF, const.OBJECT_DETECTION):
            return gr.inputs.Image(shape=kwargs.get("image_shape"), label=label)

        if self.api_type == const.TXT_CLF:
            return gr.inputs.Textbox(lines=2, placeholder=kwargs.get("text_placeholder"), label=label)
        raise NotImplementedError(f"{self.api_type} API Type is not implemented yet!")

    def single_x_classification(self, x: np.ndarray):
        data_processor = self.data_processor

        if data_processor.preprocess_fn:
            x = data_processor.preprocess(x, **self.preprocess_conf)
        x = self.model(x)
        if data_processor.postprocess_fn:
            x = data_processor.postprocess(x, **self.postprocess_conf)
        return x

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…