You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

example_init.py 770 B

12345678910111213141516171819202122232425
  1. import os
  2. import joblib
  3. import numpy as np
  4. from learnware.model import BaseModel
  5. from .model import ConvModel
  6. import torch
  7. class Model(BaseModel):
  8. def __init__(self):
  9. dir_path = os.path.dirname(os.path.abspath(__file__))
  10. self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
  11. self.model = ConvModel(channel=3, n_random_features=10).to(self.device)
  12. self.model.load_state_dict(torch.load(os.path.join(dir_path, "conv_model.pth")))
  13. self.model.eval()
  14. def fit(self, X: np.ndarray, y: np.ndarray):
  15. pass
  16. def predict(self, X: np.ndarray) -> np.ndarray:
  17. X = torch.Tensor(X).to(self.device)
  18. return self.model(X)
  19. def finetune(self, X: np.ndarray, y: np.ndarray):
  20. pass

基于学件范式,全流程地支持学件上传、检测、组织、查搜、部署和复用等功能。同时,该仓库作为北冥坞系统的引擎,支撑北冥坞系统的核心功能。