-
Notifications
You must be signed in to change notification settings - Fork 5
/
run.py
60 lines (43 loc) · 1.24 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import click
from gevent import monkey
monkey.patch_all()
import importme
importme.init()
from base import SnippetMerge, ThumbnailSpider, ThumbnailProcess, CNNModel
@click.group()
def cli():
pass
@cli.command()
@click.argument('bj_id')
def thumbnail(bj_id):
"""get thumbnails by bj_id"""
spider = ThumbnailSpider(bj_id)
spider.run(login=True)
@cli.command()
@click.argument('bj_id')
@click.argument('station_num')
def fix_thumbnail(bj_id, station_num):
"""fix thumbnail by station_num"""
spider = ThumbnailSpider(bj_id)
spider.fix(station_num=int(station_num), login=True)
@cli.command()
@click.argument('bj_id')
def train(bj_id):
"""cnn model train"""
model = CNNModel(bj_id)
model.train()
@cli.command()
@click.argument('bj_id')
@click.argument('station_num')
@click.option('--tar_sec', type=int, default=60)
def vod(bj_id, station_num, tar_sec):
"""create target video"""
# TODO:多个会报错
ThumbnailProcess(bj_id).split_img(station_num)
model_result = CNNModel(bj_id).local_run(station_num, tar_sec=tar_sec)
if model_result:
SnippetMerge(bj_id).run(station_num, tar_time_range=model_result)
if __name__ == '__main__':
cli()