前言
在参加华为云AI大赛的过程中,经常遇到的就是要编写custom_service.py, 今天来总结一下编写这个文件的一些注意事项。下面给出了一个例程进行分析。
例程
# !/usr/bin/python
# -*- coding: UTF-8 -*-
import json
try:
from model_service.pytorch_model_service import PTServingBaseService
except:
PTServingBaseService = object
import torch
import os
import numpy as np
from model import MyModel
import pathlib
class RadioMapService(PTServingBaseService):
def __init__(self, model_name, model_path):
print('--------------------init--------------------')
self.model_name = model_name
self.model_path = model_path
print(f"model_name:{model_name}")
print(f"model_pa