From fd3f95eff91130e6840ff93d37edd16723b0bbfe Mon Sep 17 00:00:00 2001 From: Xiaozhe Yao Date: Mon, 29 Oct 2018 18:12:23 +0800 Subject: [PATCH] add some go doc and online documents --- cli/config.go | 9 ++++ cli/daemon.go | 16 +++++- cli/handler.go | 12 +++++ cli/main.go | 8 +++ docs/en-US/guide/credits.md | 2 +- docs/en-US/guide/write-package.md | 84 ++++++++++++++++++++++++++++++- docs/zh-CN/guide/README.md | 4 ++ 7 files changed, 132 insertions(+), 3 deletions(-) diff --git a/cli/config.go b/cli/config.go index 57c0235cf..04c461972 100644 --- a/cli/config.go +++ b/cli/config.go @@ -1,3 +1,12 @@ +/* + This file handles config related tasks, include: + readConfig() + writeConfig() + validateConfig() + getDefaultConfig() + + The config file is located at the home dir of current user, under ~/cvpm/config.toml +*/ package main import ( diff --git a/cli/daemon.go b/cli/daemon.go index 68193768a..bc75bceb5 100644 --- a/cli/daemon.go +++ b/cli/daemon.go @@ -1,3 +1,8 @@ +/* + This file handles daemon and services related tasks. + By using cvpm daemon install, it will install a system service under current user. + You can uninstall that service by using cvpm daemon uninstall +*/ package main import ( @@ -5,11 +10,13 @@ import ( "github.com/gin-gonic/gin" "net/http" ) - +// Default Running Port const DaemonPort = "10590" +// Definition of Running Repos var RunningRepos []Repository +// Struct of a Request to Run Repo type RunRepoRequest struct { Name string `json:name` Vendor string `json:vendor` @@ -17,6 +24,7 @@ type RunRepoRequest struct { Port string `json:port` } +// Handle Post Request -> Run a Repo func PostRepoHandler(c *gin.Context) { var runRepoRequest RunRepoRequest c.BindJSON(&runRepoRequest) @@ -26,10 +34,16 @@ func PostRepoHandler(c *gin.Context) { }) } +// Handle Get Request -> Get Running Repo func GetReposHandler(c *gin.Context) { c.JSON(http.StatusOK, RunningRepos) } +/* Run the Server and Do Mount Endpoint + /status -> Get to fetch System Status + /repo -> Post to Run a Repo + /repos -> Get to fetch Running Repos +*/ func runServer(port string) { color.Red("Initiating") r := gin.Default() diff --git a/cli/handler.go b/cli/handler.go index d1abbc5ff..751f969cd 100644 --- a/cli/handler.go +++ b/cli/handler.go @@ -1,3 +1,11 @@ +/* + This file defines the handlers for different command. + Login + Install + List + Repo + and etc. +*/ package main import ( @@ -17,6 +25,7 @@ import ( "syscall" ) +// Handle User Login func LoginHandler(c *cli.Context) User { reader := bufio.NewReader(os.Stdin) fmt.Printf("Username: ") @@ -30,6 +39,7 @@ func LoginHandler(c *cli.Context) User { return currentUser } +// Handle installation func InstallHandler(c *cli.Context) { config := readConfig() localFolder := config.Local.LocalFolder @@ -58,6 +68,7 @@ func InstallHandler(c *cli.Context) { writeConfig(config) } +// Handle List func listRepos(c *cli.Context) { config := readConfig() table := tablewriter.NewWriter(os.Stdout) @@ -68,6 +79,7 @@ func listRepos(c *cli.Context) { table.Render() } +// Handle Daemon Related func DaemonHandler(c *cli.Context) { params := c.Args().Get(0) switch params { diff --git a/cli/main.go b/cli/main.go index 879b43182..2f6e69fea 100644 --- a/cli/main.go +++ b/cli/main.go @@ -1,3 +1,11 @@ +/* +Package CVPM (main) implements the CLI for CVPM. +To get started, use: + +cvpm help + +to get a detailed explanation. +*/ package main import ( diff --git a/docs/en-US/guide/credits.md b/docs/en-US/guide/credits.md index 8ae456b2b..43619eead 100644 --- a/docs/en-US/guide/credits.md +++ b/docs/en-US/guide/credits.md @@ -8,7 +8,7 @@ We would like to extend our sincere appreciate for the following organizations and individuals for their kind help during the development and production of CVPM. * [Shenzhen University](https://www.szu.edu.cn) for providing lots of general help. -* [Oregon State University Open Source Lab](https://www.google.com.hk/search?q=osuosl&oq=osusl&aqs=chrome.1.69i57j0l5.2563j1j4&sourceid=chrome&ie=UTF-8) for hosting open source and public models. +* [Oregon State University Open Source Lab](https://osuosl.org/) for hosting open source and public models. * [Netlify](https://www.netlify.com/) for providing CI/CD for documentation. * [Clarifai](https://clarifai.com/) for providing image recognition models. * [Amazon Web Services](https://aws.amazon.com) for providing general web services. diff --git a/docs/en-US/guide/write-package.md b/docs/en-US/guide/write-package.md index f4772d147..2de7bead6 100644 --- a/docs/en-US/guide/write-package.md +++ b/docs/en-US/guide/write-package.md @@ -52,15 +52,97 @@ This chapter and its related function may have broken changes recently. ([#64](h ### cvpm.toml +cvpm.toml is the entry file that tells the cvpm system which solver it should looking for. It uses [toml](https://github.com/toml-lang/toml) syntax and should looks like the following format: + +``` toml +[package] +name="Your_Package_Name" + +[[solvers]] +name="Your_Solver_1_Name" +class="path/to_your_folder/Solver_Class_Name" + +[[solvers]] +name="Your_Solver_2_Name" +class="path/to_your_folder/Solver_Class_Name" + +[[solvers]] +name="Your_Solver_3_Name" +class="path/to_your_folder/Solver_Class_Name" +``` + +For example, the Face Utility that we provided as one of our official models have the [cvpm.toml](https://github.com/cvmodel/Face_Utility/blob/master/cvpm.toml) file as following: + +``` toml +[package] +name="Face_utility" + +[[solvers]] +name="Face_Detection" +class="face_utility/solver/FaceDetectionSolver" + +[[solvers]] +name="Face_Landmark" +class="face_utility/solver/FaceLandmarkSolver" + +[[solvers]] +name="Face_Encoding" +class="face_utility/solver/FaceEncodingSolver" +``` + +Make sure this file is located at the root path of your project. + ### Pre-trained models +In most occasions, your algorithms (or neural networks etc.) should be uploaded along with some pre-trained models. We encourage you to upload it with our CLI (Not Done yet. [#72](https://github.com/unarxiv/CVPM/issues/72)), but it is also allowed if you upload it another downloadable services. + +You need to define your pre-trained models in ```pretrained/pretrained.toml``` file as following using [toml syntax](https://github.com/toml-lang/toml): + +``` toml +[[models]] +name = "model_file_name" +url = "https://www.example.com/your_model_file.zip" # Remote File + +[[models]] +name = "model_file_name" +url = "pretrained/name_of_your_modelfile" # Local File +``` + +For example, the Face Utility that we provided as one of our official models have the [pretrained.toml](https://github.com/cvmodel/Face_Utility/blob/master/pretrained.toml) file as following: + +``` toml +[[models]] +name = "dlib_face_recognition_resnet_model_v1" +url = "https://premium.file.cvtron.xyz/data/dlib_face_recognition_resnet_model_v1.dat" + +[[models]] +name = "mmod_human_face_detector" +url = "https://premium.file.cvtron.xyz/data/mmod_human_face_detector.dat" + +[[models]] +name = "shape_predictor_5_face_landmarks" +url = "https://premium.file.cvtron.xyz/data/shape_predictor_5_face_landmarks.dat" + +[[models]] +name = "shape_predictor_68_face_landmarks" +url = "https://premium.file.cvtron.xyz/data/shape_predictor_68_face_landmarks.dat" +``` + +Make sure this file is located at the ```pretrained``` subfolder of your project. + +### Pre/Post Install Scripts + +::: tip It is an ongoing plan and have not been implemented yet. ([#49](https://github.com/unarxiv/CVPM/issues/49)) ::: + ## Publish to Model Hub + + ## Publish to GitHub When publishing to GitHub, mention "CVPM Available" at the top of your README file, only if you want you model to be searchable by the Model Hub. -Your README file should be look like +Your README file should be look like the following: ``` ## PROJECT NAME diff --git a/docs/zh-CN/guide/README.md b/docs/zh-CN/guide/README.md index 1079fc02e..be06fbb72 100644 --- a/docs/zh-CN/guide/README.md +++ b/docs/zh-CN/guide/README.md @@ -21,6 +21,10 @@ CVPM is a package manager for computer vision. It helps you to download, install Full documentation can be found [here](https://cvpm.autoai.org). +## News + +* *[2018-10-29]* The development of CVPM is under heavy development and we have changed many api designs in the last 2 weeks. There might be some minor differences in the documentation because of that broken change. We **Strongly** recommend you to wait until the next official release (v0.1). It is supposed to be the first stable version, and there should not be any major api changes since that. + ## Contributing If you found a security bugs, please do not post it in issues or any other public forum. You can send me [email](mailto:xiaozhe.yaoi@qq.com) directly.