Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
feat(cli): add py_path in parser to load external modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Aug 20, 2019
1 parent a57892f commit f7beae7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
4 changes: 3 additions & 1 deletion gnes/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
'get_perm', 'time_profile', 'set_logger',
'batch_iterator', 'batching', 'yaml',
'profile_logger', 'load_contrib_module',
'parse_arg', 'profiling', 'FileLock', 'train_required', 'get_first_available_gpu']
'parse_arg', 'profiling', 'FileLock',
'train_required', 'get_first_available_gpu',
'PathImporter']


def get_first_available_gpu():
Expand Down
3 changes: 2 additions & 1 deletion gnes/preprocessor/video/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ def apply(self, doc: 'gnes_pb2.Document') -> None:
hash_v = [phash_descriptor(_).hash for _ in frames]
hash_v = np.array(hash_v, dtype=np.int32).reshape([len(hash_v), -1])
label_v = KMeans(n_clusters=self.segment_num).fit_predict(hash_v)
sub_videos = [[frames[i] for i, j in enumerate(label_v) if j == _] for _ in range(self.segment_num)]
sub_videos = [[frames[i] for i, j in enumerate(label_v) if j == _] for _ in
range(self.segment_num)]
else:
sub_videos = [frames]

Expand Down
22 changes: 3 additions & 19 deletions gnes/proto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import uuid
import ctypes
import random
from typing import List
from typing import Optional

import numpy as np
import zmq
import random
import ctypes
from termcolor import colored

from . import gnes_pb2
from ..helper import batch_iterator

__all__ = ['send_message', 'recv_message', 'blob2array', 'array2blob', 'gnes_pb2', 'add_route']
__all__ = ['RequestGenerator', 'send_message', 'recv_message', 'blob2array', 'array2blob', 'gnes_pb2', 'add_route']


class RequestGenerator:
Expand Down Expand Up @@ -106,21 +105,6 @@ def router2str(m: 'gnes_pb2.Message') -> str:
return colored('▸', 'green').join([r.service for r in m.envelope.routes])


def new_envelope(client_id: str,
request_id: str = str(uuid.uuid4()),
num_part: int = 1,
part_id: int = 1,
timeout: int = 5000) -> 'gnes_pb2.Envelope':
evlp = gnes_pb2.Envelope()
evlp.client_id = client_id
evlp.request_id = request_id
evlp.part_id = part_id
evlp.num_part.append(num_part)
evlp.timeout = timeout
add_route(evlp, client_id)
return evlp


def add_route(evlp: 'gnes_pb2.Envelope', name: str):
r = evlp.routes.add()
r.service = name
Expand Down

0 comments on commit f7beae7

Please sign in to comment.