Documentation ¶
Index ¶
- Constants
- Variables
- func AddMissingTritonModelFolder(dir string)
- func ArtiVCClone(dir string, modelConfig datamodel.ArtiVCModelConfiguration, ...) error
- func ArtiVCGetTags(dir string, config datamodel.ArtiVCModelConfiguration) ([]string, error)
- func ConvertAllJSONEnumValueToProtoStyle(enumRegistry map[string]map[string]int32, i interface{})
- func ConvertAllJSONKeySnakeCase(i interface{})
- func ConvertModelToResourceName(modelName string) string
- func CopyModelFileToModelRepository(modelRepository string, dir string, tritonModels []datamodel.TritonModel) error
- func DoSupportBatch(configFilePath string) (bool, error)
- func GenerateHuggingFaceModel(confDir string, dest string, modelID string) error
- func GetJSON(url string, result interface{}) error
- func GetMaxBatchSize(configFilePath string) (int, error)
- func GetSupportedBatchSize(task datamodel.ModelTask) int
- func GitHubClone(dir string, instanceConfig datamodel.GitHubModelConfiguration, ...) error
- func HasModelWeightFile(modelRepository string, tritonModels []datamodel.TritonModel) bool
- func HuggingFaceClone(dir string, modelConfig datamodel.HuggingFaceModelConfiguration) error
- func HuggingFaceExport(dir string, modelConfig datamodel.HuggingFaceModelConfiguration, ...) error
- func RemoveModelRepository(modelRepositoryRoot string, namespace string, modelName string, ...)
- func SaveFile(stream modelPB.ModelPublicService_CreateModelBinaryFileUploadServer) (outFile string, modelInfo *datamodel.Model, modelDefinitionID string, ...)
- func Unzip(fPath string, dstDir string, owner string, uploadedModel *datamodel.Model) (string, string, error)
- func UpdateConfigModelName(filePath string, oldModelName string, newModelName string) error
- func UpdateModelConfig(modelRepository string, tritonModels []datamodel.TritonModel) error
- func UpdateModelName(filePath string, oldModelName string, newModelName string) error
- func UpdateModelPath(modelDir string, dstDir string, owner string, model *datamodel.Model) (string, string, error)
- func ValidateFilePath(filePath string) error
- func WriteToFp(fp *os.File, data []byte) error
- type CacheModel
- type FileMeta
- type GitHubInfo
- type ModelMeta
- type Tag
Constants ¶
const ( KB = 1 << (10 * iota) MB GB TB )
const ( TEXT_TO_IMAGE_STEPS = int64(10) IMAGE_TO_TEXT_CFG_SCALE = float32(7) IMAGE_TO_TEXT_SEED = int64(1024) IMAGE_TO_TEXT_SAMPLES = int64(1) )
const ( TEXT_GENERATION_OUTPUT_LEN = int64(100) TEXT_GENERATION_TOP_K = int64(1) TEXT_GENERATION_SEED = int64(0) )
const DEFAULT_GCP_SERVICE_ACCOUNT_FILE = "https://artifacts.instill.tech/default-service-account.json"
const DefaultPageSize = 10
const MODEL_CACHE_DIR = "/.cache/models"
const MODEL_CACHE_FILE = "cached_models.json"
const MaxBatchSize int = 32
Variables ¶
var MarshalOptions protojson.MarshalOptions = protojson.MarshalOptions{ UseProtoNames: true, EmitUnpopulated: true, UseEnumNumbers: false, }
var Tags = map[string]modelPB.Model_Task{ "CLASSIFICATION": modelPB.Model_TASK_CLASSIFICATION, "DETECTION": modelPB.Model_TASK_DETECTION, "IMAGE-CLASSIFICATION": modelPB.Model_TASK_CLASSIFICATION, "IMAGE-DETECTION": modelPB.Model_TASK_DETECTION, "OBJECT-DETECTION": modelPB.Model_TASK_DETECTION, "OCR": modelPB.Model_TASK_OCR, "INSTANCESEGMENTATION": modelPB.Model_TASK_INSTANCE_SEGMENTATION, "INSTANCE_SEGMENTATION": modelPB.Model_TASK_INSTANCE_SEGMENTATION, "SEMANTIC_SEGMENTATION": modelPB.Model_TASK_SEMANTIC_SEGMENTATION, "SEMANTICSEGMENTATION": modelPB.Model_TASK_SEMANTIC_SEGMENTATION, "TEXT_TO_IMAGE": modelPB.Model_TASK_TEXT_TO_IMAGE, "TEXTTOIMAGE": modelPB.Model_TASK_TEXT_TO_IMAGE, "TEXT_GENERATION": modelPB.Model_TASK_TEXT_GENERATION, "TEXTGENERATION": modelPB.Model_TASK_TEXT_GENERATION, }
var Tasks = map[string]modelPB.Model_Task{ "TASK_CLASSIFICATION": modelPB.Model_TASK_CLASSIFICATION, "TASK_DETECTION": modelPB.Model_TASK_DETECTION, "TASK_KEYPOINT": modelPB.Model_TASK_KEYPOINT, "TASK_OCR": modelPB.Model_TASK_OCR, "TASK_INSTANCESEGMENTATION": modelPB.Model_TASK_INSTANCE_SEGMENTATION, "TASK_INSTANCE_SEGMENTATION": modelPB.Model_TASK_INSTANCE_SEGMENTATION, "TASK_SEMANTIC_SEGMENTATION": modelPB.Model_TASK_SEMANTIC_SEGMENTATION, "TASK_SEMANTICSEGMENTATION": modelPB.Model_TASK_SEMANTIC_SEGMENTATION, "TASK_TEXT_TO_IMAGE": modelPB.Model_TASK_TEXT_TO_IMAGE, "TASK_TEXTTOIMAGE": modelPB.Model_TASK_TEXT_TO_IMAGE, "TASK_TEXT_GENERATION": modelPB.Model_TASK_TEXT_GENERATION, "TASK_TEXTGENERATION": modelPB.Model_TASK_TEXT_GENERATION, }
var UnmarshalOptions protojson.UnmarshalOptions = protojson.UnmarshalOptions{ DiscardUnknown: true, }
var Visibility = map[string]modelPB.Model_Visibility{ "public": modelPB.Model_VISIBILITY_PUBLIC, "private": modelPB.Model_VISIBILITY_PRIVATE, }
Functions ¶
func AddMissingTritonModelFolder ¶
func AddMissingTritonModelFolder(dir string)
func ArtiVCClone ¶
func ArtiVCClone(dir string, modelConfig datamodel.ArtiVCModelConfiguration, withLargeFiles bool) error
func ArtiVCGetTags ¶
func ArtiVCGetTags(dir string, config datamodel.ArtiVCModelConfiguration) ([]string, error)
func ConvertAllJSONEnumValueToProtoStyle ¶
ConvertAllJSONEnumValueToProtoStyle converts lowercase enum value to the Protobuf naming convention where the enum type is always prefixed and is UPPERCASE snake_case. For examples: - api in a Protobuf `Enum SourceType` type will be converted to SOURCE_TYPE_API - oauth2.0 in a Protobuf `Enum AuthFlowType` type will be converted to AUTH_FLOW_TYPE_OAUTH2_0
func ConvertAllJSONKeySnakeCase ¶
func ConvertAllJSONKeySnakeCase(i interface{})
ConvertAllJSONKeySnakeCase traverses a JSON object to replace all keys to snake_case.
func CopyModelFileToModelRepository ¶
func CopyModelFileToModelRepository(modelRepository string, dir string, tritonModels []datamodel.TritonModel) error
CopyModelFileToModelRepository copies model files to model repository.
func DoSupportBatch ¶
func GetJSON ¶
GetJSON fetches the contents of the given URL and decodes it as JSON into the given result, which should be a pointer to the expected data.
func GetMaxBatchSize ¶
func GetSupportedBatchSize ¶
func GitHubClone ¶
func GitHubClone(dir string, instanceConfig datamodel.GitHubModelConfiguration, isWithLargeFile bool) error
GitHubClone clones a repository from GitHub.
func HasModelWeightFile ¶
func HasModelWeightFile(modelRepository string, tritonModels []datamodel.TritonModel) bool
func HuggingFaceClone ¶
func HuggingFaceClone(dir string, modelConfig datamodel.HuggingFaceModelConfiguration) error
func HuggingFaceExport ¶
func HuggingFaceExport(dir string, modelConfig datamodel.HuggingFaceModelConfiguration, modelID string) error
func RemoveModelRepository ¶
func Unzip ¶
func Unzip(fPath string, dstDir string, owner string, uploadedModel *datamodel.Model) (string, string, error)
TODO: need to clean up this function
func UpdateConfigModelName ¶
func UpdateModelConfig ¶
func UpdateModelConfig(modelRepository string, tritonModels []datamodel.TritonModel) error
func UpdateModelName ¶
func UpdateModelPath ¶
func UpdateModelPath(modelDir string, dstDir string, owner string, model *datamodel.Model) (string, string, error)
modelDir and dstDir are absolute path
func ValidateFilePath ¶
validate to prevent security issue as https://codeql.github.com/codeql-query-help/go/go-path-injection/
Types ¶
type CacheModel ¶
type GitHubInfo ¶
type GitHubInfo struct { Description string `json:"description"` Visibility string `json:"visibility"` Tags []Tag }
func GetGitHubRepoInfo ¶
func GetGitHubRepoInfo(repo string) (*GitHubInfo, error)