Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
feat(cli): add py_path in parser to load external modules
  • Loading branch information
hanhxiao committed Aug 20, 2019
1 parent a57892f commit f7beae7bd5dba146f7465bf16682ae30002ee5a5
Showing with 8 additions and 21 deletions.
  1. +3 −1 gnes/helper.py
  2. +2 −1 gnes/preprocessor/video/ffmpeg.py
  3. +3 −19 gnes/proto/__init__.py
@@ -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():
@@ -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]

@@ -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:
@@ -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

0 comments on commit f7beae7

Please sign in to comment.