Skip to content

Instantly share code, notes, and snippets.

Experiments using TorchServe to run PULSE mode

Install

https://github.com/pytorch/serve#install-torchserve-and-torch-model-archiver

Serve a model as a RESTful API

Achive the model

torch-model-archiver --model-name pulse --version 1.0 --model-file PULSE.py --serialized-file model.pt --export-path ./model_store --handler pulse_serve_handler:entry_point_function_name --extra-files PULSE.py,align_face.py,bicubic.py,drive.py,gaussian_fit.pt,loss.py,mapping.pt,SphericalOptimizer.py,shape_predictor.py,stylegan.py,synthesis.pt -f
@huangzhuolin
huangzhuolin / linear-algebra-with-applications.md
Last active June 27, 2019 13:02
[linear algebra with applications]

linear algebra with applications

Matrices and Systems of Equations

Systems of Linear Equations

  • strict triangular form

    A system is said to be in strict triangular form if, in the kth equation, the coefficients of the first k-1 variables are all zero and the coefficient of $x_{k}$ is nonzero.

  • Elementary Row Operations
  • I. Interchange two rows.
@huangzhuolin
huangzhuolin / ielts-notes.md
Last active July 9, 2019 12:45
[ielts-notes] #english

Four parts of the exam

Listening

Reading

Two questions one time

Divide and conquer. If a part has 5 questions, we can read 2 of them one time.

@huangzhuolin
huangzhuolin / develop-form-with-antd.md
Last active October 29, 2018 02:10
Use antd to develop form #antd #frontend

Use antd to develop form

Keep UI layer clean

In React, the UI layer means the render function of the page component. Because of the flexibility of React, redundant logic are usually put into the render method, which will easily lead to tremendous render methods. When using antd.Form component, initial values of form fields, form validation, transformation of form values to the UI components' props are all defined in page component. But this may not be a good practice. A clean render method of page component should only concern about the representation logic, for example, the layout of components and user interactions.

To achieve this goal, where to place the initialization, validation of form, and the transformation of form values to components' props need to be taken into account. First, antd form's getFieldDecorator method declare s the behaviour of one field with an configuration object. The object contains initial value of the field, the validating rules, and some tranformation function

@huangzhuolin
huangzhuolin / index.sql
Created September 14, 2018 02:53
[mysql select case when] #mysql
select case field_a
when '1' then 'cat'
when '2' then 'dog'
else 'unknown'
end
from my_table;
@huangzhuolin
huangzhuolin / index.md
Last active August 30, 2018 02:58
[implement dashboard like grafana using highstock] #react #highcharts

In grafana, when we click in the chart and drag, we can select the time range to display. The effect will be propagated to the whole dashboard, and every panel will be set to the specific time range.

Now we try to realize the same effect using React and Highcharts.

  1. The highchart's option to enable the function that we can drag to select time range is below.
{
  chart: { zoomType: 'x' }
}
@huangzhuolin
huangzhuolin / componentCtrl.js
Created August 2, 2018 10:11
[pass function as parameter to component in anglularjs] #angularjs
// ...
export class ComponentCtrl {
// ...
onClick() {
// We can access outer scope function here with the binding name.
this.outerHandleClick({param1: 1, param2: 2}) // We can also pass parameters to outer function.
}
}
@huangzhuolin
huangzhuolin / angularjs-directives.md
Last active July 3, 2018 08:53
[angularjs directives] #angularjs

Directives

refs

https://docs.angularjs.org/guide/directive

Definition

At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.

matching directives

  1. `` element matches the ngModel directive
@huangzhuolin
huangzhuolin / flags.py
Created June 28, 2018 12:51
[downloading with concurrent.futures] web downloads in three styles #python
# sequential download script
import os
import time
import sys
import requests
POP20_CC = ('CN IN US ID BR PK NG BD RU JP '
'MX PH VN ET EG DE IR TR CD FR').split()
@huangzhuolin
huangzhuolin / python-iterable-and-iterator.md
Last active June 20, 2018 08:49
[python iterable, iterator and generator function] #python

differences between iterables and iterators

iterables have an __iter__ method that instantiates a new iterator every time. iterators implement a __next__ method that returns individual items, and an __iter__ method that returns self.

Therefore, iterators are also iterable, but iterables are not iterators.

generator function