Exemple #1
0
 def status(self):
     from wk import PointDict
     info=PointDict(
         current_branch=self.space.active_branch(),
         branches=self.space.branch_list(),
         status=self.space.status(silent=True)
     )
     if self.space.active_branch()=='master':
         info.store_keys=self.keys()
     # info.print()
     print(info)
     return info
Exemple #2
0
def make_trainval_config(cfg, data_cfg):
    cfg = PointDict(**cfg)
    data_cfg = PointDict(**data_cfg)

    class Config(TrainValConfigBase):
        MODEL_TYPE = cfg.MODEL_TYPE
        GEN_CLASSES_FILE = cfg.GEN_CLASSES_FILE
        USE_tqdm_TRAIN = cfg.USE_tqdm_TRAIN
        INPUT_SIZE = (cfg.INPUT_W, cfg.INPUT_H)
        BATCH_SIZE = cfg.BATCH_SIZE
        NUM_EPOCHS = cfg.NUM_EPOCHS
        BALANCE_CLASSES = cfg.BALANCE_CLASSES
        VAL_INTERVAL = cfg.VAL_INTERVAL
        WEIGHTS_SAVE_INTERVAL = cfg.WEIGHTS_SAVE_INTERVAL
        WEIGHTS_INIT = cfg.WEIGHTS_INIT
        TRAIN_DIR = cfg.TRAIN_DIR
        VAL_DIR = cfg.VAL_DIR
        INPUT_W = cfg.INPUT_W
        INPUT_H = cfg.INPUT_H
        val_transform = EasyTransform([
            t.Resize(INPUT_SIZE[::-1]),
            t.SaveToDir(cfg.VISUALIZE_RESULT_DIR),
            t.ToTensor(),
        ])
        train_transform = EasyTransform(
            list(
                filter(lambda x: x is not None, [
                    t.ColorJitter(brightness=data_cfg.BRIGHTNESS,
                                  contrast=data_cfg.CONTRAST,
                                  saturation=data_cfg.SATURATION,
                                  hue=data_cfg.HUE),
                    t.RandomHorizontalFlip()
                    if data_cfg.RandomHorizontalFlip else None,
                    t.RandomVerticalFlip()
                    if data_cfg.RandomVerticalFlip else None,
                    t.RandomRotate(data_cfg.RandomRotate)
                    if data_cfg.RandomRotate else None,
                    t.RandomShear(data_cfg.RandomShear, data_cfg.RandomShear)
                    if data_cfg.RandomShear else None,
                    t.RandomTranslate(data_cfg.RandomTranslate)
                    if data_cfg.RandomTranslate else None,
                    t.RandomBlur(p=data_cfg.RandomBlur, radius=1)
                    if data_cfg.RandomBlur else None,
                    t.RandomSPNoise(p=data_cfg.RandomSPNoise)
                    if data_cfg.RandomSPNoise else None,
                    *val_transform,
                ])))

    return Config
Exemple #3
0
 def status(self, repo=None):
     repo = repo or self.repo
     from wk import PointDict
     info = PointDict(current_branch=repo.active_branch(),
                      local_branches=repo.branch_list(),
                      status=repo.status())
     print(info)
     return info
Exemple #4
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args)
     self.update(
         builtin=PointDict(len=len, ),
         utils=PointDict(
             wk=wk,
             jsonify=web.jsonify,
             to_datetime_str=wk.to_datetime_str,
             to_date_str=wk.to_date_str,
         ),
         user=None,
         URL=URL,
         get_user=app.usman.get_user,
         get_article=app.document_engine.get,
         get_user_link=lambda id: join_path(URL.prefix.user, id),
         get_article_link=lambda aid: join_path(
             URL.prefix.article, aid),
     )
     self.update(**kwargs)
Exemple #5
0
 def get(self, arg, default=EmptyArgument):
     EmptyKey = ArgumentSpace.EmptyKey
     v = PointDict.get(self, arg, EmptyKey)
     if v is EmptyKey or v is None:
         if isinstance(self.geta('__parent__'), ArgumentSpace):
             v = self.geta('__parent__').get_argument(arg, EmptyKey)
             # print('parent v:',v)
             if v is EmptyKey:
                 # print('v is Empty')
                 if default is ArgumentSpace.EmptyArgument:
                     raise Exception('Cannot get argument %s' % (arg))
                 v = default
             # else:
             # 	print('V is not Empty')
     # print(arg,v,default)
     return v
Exemple #6
0
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5 import QtCore,QtGui,QtWidgets
import os
_root=os.path.dirname(__file__)
from wk import PointDict
g=PointDict()


class VirtualWidget:
    pass
def setAttributes(widget,kwargs):
    for k,v in kwargs.items():
        if k.startswith('on'):
            getattr(widget,k[2:]).connect(v)
        else:
            assert k.startswith('set')
            getattr(widget,k)(v)
    return widget
def addChild(widget,child):
    # print('adding %s to %s'%(child,widget))
    ws=(QWidget,QLabel,QLayout)
    assert isinstance(widget,ws)
    if isinstance(child,(QLayout,QHBoxLayout,QVBoxLayout)):
        widget.addLayout(child)
    elif isinstance(child,(QAction)):
        widget.addAction(child)
    elif isinstance(child,(QWidget)):
        widget.addWidget(child)
Exemple #7
0
        def do_search_files(user):
            args = dict(web.get_url_args())
            q = None
            if 'q' in args.keys():
                q = args.pop('q')

            subjects = dict(chinese='语文',
                            math='数学',
                            english='英语',
                            physics='物理',
                            chemistry='化学',
                            biology='生物',
                            history='历史',
                            politics='政治',
                            geography='地理')
            if 'subject' in args:
                args['subject'] = subjects[args['subject']]
            categories = {
                '语文': {
                    '知识点': {
                        '必修一': None,
                        '必修二': None,
                        '必修三': None,
                    },
                    '学习方法': None,
                    '思维导图': None,
                },
                '数学': {
                    '知识点': {
                        '必修一': None,
                        '必修二': None,
                        '必修三': None,
                    },
                    '学习方法': None,
                    '思维导图': None,
                },
                '英语': None,
            }
            context = Context(user=user,
                              categories=json.dumps(categories,
                                                    ensure_ascii=False,
                                                    indent=2),
                              recommendations=[],
                              filters=[
                                  PointDict(name='subject',
                                            title='科目',
                                            choices=[
                                                PointDict(title=v, name=k)
                                                for k, v in subjects.items()
                                            ])
                              ])

            if not q and not args:
                return pages.FileSearchPageBase().render(context=context)
            filters = args
            result = self.static_storage_engine.select(**filters)
            if q:
                result = self.static_storage_engine.search(q,
                                                           candidates=result)
            result = [
                self.static_storage_engine.get_file_info(file)
                for file in result
            ]
            for file in result:
                file['url'] = join_path(URL.prefix.static_files, file['id'])
            print("所搜到%s条结果" % (len(result)))
            x = pages.FileSearchPageBase().compile().render(input_fill=q,
                                                            files=result,
                                                            context=context)
            return x