Skip to content

Commit

Permalink
add write package
Browse files Browse the repository at this point in the history
  • Loading branch information
xzyaoi committed Oct 15, 2018
1 parent 79adb31 commit 069666d
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/en-US/guide/write-package.md
Expand Up @@ -4,9 +4,49 @@

### Project Structure

Your package is firstly a Python Package. Therefore, it will look like:

```
- example_package
- example_package
- solver.py
- bundle.py
- pretrained
- pretrained.toml
- tests // optional
- examples // optional
- cvpm.toml
- requirements.txt
- README.md
```

### Solvers

Solver is a ```class``` extended from ```cvpm.Solver``` class. In this class, you need to implement 2 functions: ```__init__``` and ```infer```. As their literal meanings, in the ```init``` function, parameters that your infer functions use should be initiate, and in the ```infer``` function, a image file path will be passed in the parameter, and the ```infer``` function is supposed to return your result in a dict or list.

For example, a simple solver frame will look like

``` python
from cvpm.solver import Solver

class SampleSolver(Solver):
def __init__(self, toml_file=None):
super().__init__(toml_file)
# Do you Init Work here
self.classifer = get_classifier()
self.set_ready()
def infer(self, image_file, config):
# Use your own load_image method, or from cvpm.utility import load_image_file
image = load_image(image_file)
result = self.classifier(image)
return result
```

### Bundle

::: tip 注意 请确保你的 Node.js 版本 >= 8。 :::



### cvpm.toml

Expand All @@ -27,4 +67,5 @@ Your README file should be look like
```

You can look at [Face Utility](https://github.com/cvmodel/Face_Utility) for reference that we provided as an official repository.

## Best Practice

0 comments on commit 069666d

Please sign in to comment.