示例#1
0
def test_model(sess, minibatch):
    # test and validate model
    if conf.test_mode:
        run_batch(sess, mtest, test_data, tf.no_op(), minibatch)

    t_train = MyThread(run_batch, (sess, m, train_data, tf.no_op(), minibatch))
    t_test = MyThread(run_batch,
                      (sess, mtest, test_data, tf.no_op(), minibatch))
    t_val = MyThread(run_batch, (sess, mval, val_data, tf.no_op(), minibatch))

    t_train.start()
    t_test.start()
    t_val.start()

    t_train.join()
    result_train = t_train.get_result()
    t_test.join()
    result_test = t_test.get_result()
    t_val.join()
    result_val = t_val.get_result()

    print("Train cost {0:0.3f}, Acc {1:0.3f}".format(result_train[0],
                                                     result_train[1]))
    print("Valid cost {0:0.3f}, Acc {1:0.3f}".format(result_val[0],
                                                     result_val[1]))
    print("Test  cost {0:0.3f}, Acc {1:0.3f}".format(result_test[0],
                                                     result_test[1]))

    return result_train + result_test + result_val
    def __init__(self, opt=1):

        ##########################
        ##### default saving directory
        ##########################
        self.default_path = '/Users/virginiarutten/Documents/deep_fish/videos'
        self.filename = 'test'
        self.ext = '.avi'

        self.dt = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")[2:]
        self.foldername = self.default_path + '/' + self.dt[:6]
        self.path = self.get_path()
        self.check_dir()

        self.save = False
        self.cameraPort = 1

        self.recording = False
        self.trialOn = False
        self.flowOn = False
        self.ARD = False

        self.trialTime = 10
        self.trialSleepTime = 10

        ##########################
        ##### Arduino settings
        ##########################
        self.flowOffDelay = 1
        self.flowOnDelay = 1

        self.imW = int(640 / 2)
        self.imH = int(360 / 2)
        self.imfps = 25

        self.trialTimer = MyTimer()
        self.trialTimer.restart()

        self.ite = 0

        self.args = self.initialise_tracking_variables()
        self.win = self.initialise_window()
        self.recorder = self.initialise_videorecorder()
        self.Tracker = self.initialise_tracker()

        ##########################
        ##### Arduino
        ##########################
        self.ARDPort = self.ArdPortComboBox.currentData()
        self.Ard = self.initialise_Ard()

        ##########################
        ##### Threads
        ##########################
        self.recordingThread = MyThread(self.start_recording)
        self.recordingThread.start()
        self.trialThread = MyThread(self.start_trial)
        self.trialThread.start()

        self.recording = True
示例#3
0
    def __init__(self):
        super(myApp, self).__init__()
        
        # initialise gui
        self.initUI()
        
        # initialise bools
        self.measuring = False #reading from  arduino
        self.trialOn = False #trial loo
        
        ## trial thread
        self.trial_thread = MyThread(self.trial_loop)
        self.trial_thread.start()
        
        
        self.ard_thread = MyThread(self.read_ard)
        self.ard_thread.start()
        
        # try to connect to arduino
        try:
            self.get_serial()
        except:
            pass

        try:
            self.load_picture()
        except:
            pass
示例#4
0
def get_html_data(url,url_id):
    get_url = MyThread (get_response, (url,))
    get_url2 = MyThread (get_route, (url_id,))
    get_url.start (), get_url2.start ()
    get_url.join (), get_url2.join ()
    response = get_url.get_result ()
    route = get_url2.get_result ()
    return response,route
示例#5
0
def init_thread(args):
    thread_list = []
    num_max = int(100 / args.thread)
    for i in range(0, args.thread):
        thread_list.append(
            MyThread(i, f"Thread-{i + 1}", img_dl, 5, num_max - num_max,
                     num_max))
        num_max += num_max
    thread_list.append(
        MyThread(args.thread, f"Thread-{args.thread + 1}", process_aff, 5, 0,
                 num_max))
    return thread_list
示例#6
0
文件: mt3.py 项目: Ulysses-WJL/study
def main():
    print(f"函数起始时间1:{time.ctime()}")
    threads = []
    t1 = MyThread(worker, 'thread-1', (4, ))
    threads.append(t1)

    t2 = MyThread(worker, 'thread-2', (2, ))
    threads.append(t2)
    for t in threads:
        t.start()
    # for t in threads:
    #     t.join()
    # 等待结束
    # time.sleep(4)
    print(f"函数结束时间1:{time.ctime()}")
示例#7
0
    def __init__(self):
        ## 변수
        self.key = ""
        self.apiGetter = LolApiGetter()
        self.popupMaker = PopupMaker()
        self.nickname = ""

        ## 쓰레드
        self.t = MyThread()
        self.t.daemon = True  # 부모 종료 시 같이 종료
        self.t.setApiGetter(self.apiGetter)
        self.t.setPopupMaker(self.popupMaker)

        ## UI
        self.root = Tk()
        self.main_frame = Frame(self.root)
        self.main_frame.pack()

        self.label = Label(self.main_frame, text="API KEY")
        self.label.pack()
        self.txt_key = Entry(self.main_frame)
        self.txt_key.pack()

        self.label2 = Label(self.main_frame, text="소환사 이름")
        self.label2.pack()
        self.txt = Entry(self.main_frame)
        self.txt.pack()

        self.btn_ok = Button(self.main_frame,
                             text="OK",
                             command=self.setNicknameByBtn)
        self.btn_ok.pack()

        self.txt.focus_force()
        self.root.mainloop()
示例#8
0
def report_to_server(url):

    global thread
    thread = MyThread()
    thread.daemon = True
    thread.set_login_URL(url)
    thread.start()
示例#9
0
def main():
    logger = logging.getLogger('main()')
    logger.info('server start!')
    worker_threads = 4  #定义需要启动的线程数量
    timeline = 2  #线程检查时间间隔,秒
    thread_pool = {}

    for i in range(0, worker_threads):
        param = 'some param'
        job = MyJobs(param)
        thread = MyThread(job, i)
        thread.setDaemon = True
        thread.start()
        logger.info('start thread %s' % (thread.getName()))
        thread_pool[i] = thread

    #干完就结束模式
    #for eachKey in thread_pool.keys():
    # thread_pool[eachKey].join()

    #保持线程数量模式
    while 1:
        time.sleep(timeline)
        # 检查每一个线程
        for eachKey in thread_pool.keys():
            if thread_pool[eachKey].isAlive():
                print('thread alive:' + str(i))
            else:
                print('thread down:' + str(i))
                thread_pool[eachKey].run()

    logger.info('main exist!')
    return
示例#10
0
 def startThread(self):
     if self.sock:
         #thread.Thread(target=self.recvData).start()
         thread1 = MyThread().createThread(self.recvData)
         thread1.start()
         return thread1, self.sock
     else:
         return None, None
示例#11
0
    def __init__(self):
        ip, port = getUdpConfig()
        self.UDP_IP_ADDRESS = ip
        self.UDP_PORT_NO = port
        self.serverSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.serverSocket.bind((self.UDP_IP_ADDRESS, self.UDP_PORT_NO))
        print('Waiting for connection...')

        #thread.Thread(target=self.recvData).start()
        MyThread().createThread(self.recvData).start()
示例#12
0
def main():
    print("At", ctime(), "on Amazon")
    threads = []
    for isbn in ISBNS:
        threads.append(
            MyThread(func=_showRanking,
                     args=(isbn, ),
                     name=_showRanking.__name__))

    for thread in threads:
        thread.start()
示例#13
0
def Principal_function(messagerow,soup,route,subtitle,response,movie_type,Complete):
    medium = messagerow[0]
    code = messagerow[1]
    resolving_power = messagerow[2]
    Audio_coding = messagerow[3]
    region = messagerow[4]
    Production_team = messagerow[5]
    info = vidioparme(soup)
    judge_info=''
    if info[0] ==False:
        info=str(info[1])
        judge_info = '===info错误,没用quote括起来'
    else:
        info=str(info)
    x_info = re.findall('data-cfemail="(.*)" href="/cdn-cgi/l/email-protection', info)
    if x_info:
        email_ = email_jimi(x_info[0])
        info = re.sub('<a class="__cf_email__".*>', email_, info)
    title = title_get(soup)
    title_check_ans = title_check(title)
    # 创建9个线程
    task = MyThread(medium_check_All, (route, medium, info, title, soup))
    task2 = MyThread(check_code_All, (code, info, medium, route, title))
    task3 = MyThread(check_Audio_coding_All, (Audio_coding, info, Production_team, title))
    task4 = MyThread(check_resolving_power_All, (resolving_power, info, medium, route, title,movie_type))
    task5 = MyThread(check_region_all, (soup, region))
    task6 = MyThread(team_processing, (route, medium, title,info))
    task7 = MyThread(tag_check, (title, response, medium, subtitle, info, Production_team,Complete,region))
    task8 = MyThread(link_check, (soup, response))
    task9=MyThread(movie_type_check_All,(movie_type, medium, resolving_power, title))
    #task10=MyThread(img_check,(soup,imgheaders))
    task.start(),task2.start(),task3.start(),task4.start(),task5.start(),task6.start()
    task7.start(),task8.start(),task9.start(),
    task.join()
    task2.join()
    task3.join()
    task4.join()
    task5.join()
    task6.join()
    task7.join()
    task8.join()
    task9.join()
    if title_check_ans:
        title = title + title_check_ans
    return title, subtitle, task9.get_result(), messagerow, task.get_result(),task2.get_result(),task3.get_result(),\
           task4.get_result(),task5.get_result(),task6.get_result(),task7.get_result(),task8.get_result()+judge_info
示例#14
0
def main(ip='0.0.0.0', port=80):
    msock = passiveTCP(port, QLEN, ip)

    while (True):
        conn, addr = msock.accept()
        com = conn.recv(Lengh_of_communication)
        com = str(com.decode('utf-8')).strip(b'\x00'.decode())
        print(com, end=' ')
        if (com in pars.Map.keys()):
            t = MyThread(conn, pars.Map[com], filetables, con)
            t.start()
            t.join()
示例#15
0
def main():
    threads = []
    for i in range(3):
        t = MyThread(fac, (10 - i, ), fac.__name__)
        threads.append(t)

    for i in range(3):
        threads[i].start()

    for i in range(3):
        threads[i].join()
        print(threads[i].getResult())
示例#16
0
def main():
    nloops = randint(2, 5)
    q = Queue(32)
    threads = []
    for i in nfuncs:
        t = MyThread(funcs[i], (q, nloops), funcs[i].__name__)
        threads.append(t)
    for i in nfuncs:
        threads[i].start()
    for i in nfuncs:
        threads[i].join()
    print('all Done')
示例#17
0
def main_test(url):
    html = get_html(url)
    soup = get_soup(html)
    img_dirs = get_img_dirs(soup)
    if img_dirs == None:
        print("无法获取该页面下的图册内容...")

    else:
        for d in img_dirs:
            my_thread = MyThread(download_imgs, (d, img_dirs.get(d)))
            my_thread.start()
            my_thread.join()
示例#18
0
    def __init__(self, cam=1):

        self.ap = argparse.ArgumentParser()
        self.ap.add_argument("-v",
                             "--video",
                             default='./videos',
                             help="path to the video file")
        self.ap.add_argument("-f", "--fps", type=int, default=10, help="fps")

        self.ap.add_argument("-p",
                             "--path",
                             type=str,
                             default='./videos',
                             help="path to which to save videos")
        file_name = 'test' + str(np.random.randint(100))
        self.ap.add_argument("-n",
                             "--name",
                             type=str,
                             default=file_name,
                             help="filename")
        self.ap.add_argument("-r",
                             "--resize",
                             type=bool,
                             default=True,
                             help="filename")

        self.ap.add_argument("-c",
                             "--cam",
                             type=int,
                             default=1,
                             help="csamera number")

        self.args = vars(self.ap.parse_args())

        self.output = self.args['path'] + '/' + self.args['name']
        self.fps = self.args['fps']
        self.cam = self.args['cam']
        self.resize = self.args['resize']
        print(self.output)

        self.fourcc = cv2.VideoWriter_fourcc(*'XVID')
        self.imH = int(360 / 2)
        self.imW = int(640 / 2)

        self.recording = False

        self.initialiseCap()
        self.initialiseWriter()
        self.recordingThread = MyThread(self.record)
        self.recordingThread.start()
        self.Timer = MyTimer()
        self.Timer.restart()
示例#19
0
def test_model(sess, minibatch):
    # test and validate model
    if conf.test_mode:
        run_batch(sess, mtest, test_data, tf.no_op(), minibatch)

    t_train = MyThread(run_batch, (sess, m, train_data, tf.no_op(), minibatch))
    t_test = MyThread(run_batch, (sess, mtest, test_data, tf.no_op(), minibatch))
    t_val = MyThread(run_batch, (sess, mval, val_data, tf.no_op(), minibatch))

    t_train.start()
    t_test.start()
    t_val.start()

    t_train.join()
    result_train = t_train.get_result()
    t_test.join()
    result_test = t_test.get_result()
    t_val.join()
    result_val = t_val.get_result()

    result = result_train + result_test + result_val
    monitor.new(result, minibatch)
    return result
示例#20
0
def main():
    sleepTime = [2,4]
    loops = range(len(sleepTime))
    tArray = []
    for i in loops:
        t = MyThread(loop, args = (i, sleepTime[i]), name = loop.__name__)
        print(t)
        tArray.append(t)
    for i in range(len(tArray)) :
        tArray[i].start()
    for i in range(len(tArray)) :
        tArray[i].join()
        print('getResult.res:',tArray[i].getResult())
    print('all DONE at:{}'.format(ctime()))
示例#21
0
 def startTCP(self, args={}):
     # Wait for a connection
     print('waiting for a connection...')
     while True:
         try:
             connection, client_address = self.sock.accept()
             self.clientList.append(client_address)
             MyThread().createThread(self.recvData,
                                     args={
                                         'con': connection,
                                         'client': client_address
                                     }).start()
         except:
             print('server closed.')
             break
示例#22
0
def main():
    print 'starting at: ', ctime()
    threads = []
    nloops = range(len(loops))

    for i in nloops:
        t = MyThread(loop, (i, loops[i]), loop.__name__)
        threads.append(t)

    for i in nloops:
        threads[i].start()

    for i in nloops:
        threads[i].join()

    print 'all DONE at: ', ctime()
示例#23
0
def main():
    nloops = randint(2, 5)
    nfuncs = range(len(funcs))
    q = Queue(32)

    threads = list()
    for i in nfuncs:
        t = MyThread(funcs[i], (q, nloops), funcs[i].__name__)
        threads.append(t)

    for i in nfuncs:
        threads[i].start()

    for i in nfuncs:
        threads[i].join()

    print 'ALL DONE!'
示例#24
0
 def start_callback(self):
     print('开始')
     # self.text_condition.configure(text='开始')
     self.str.set('开始')
     th = MyThread(self.p, self.run)
     th.setDaemon(True)
     th.start()
     th.join()
     self.path = th.get_result()
     if self.path:
         self.printp()
         self.str.set('静止')
         step = th.get_Infor()
         self.str2.set('步数为:' + str(step))
         for i in self.path:
             print(i)
     else:
         self.str.set('计算不出来')
def main():
    print "start at:", ctime()
    threads = []
    nloops = range(len(loops))

    for i in nloops:
        thread = MyThread(loop, (i, loops[i]))
        threads.append(thread)

    for i in nloops:
        threads[i].start()

    for i in nloops:
        threads[i].join()

    for i in nloops:
        print "thread ret", threads[i].res
    print "all done at:", ctime()
示例#26
0
def main():
    nfuncs = range(len(func))
    print('*** SINGLE THREAD')
    for i in nfuncs:
        print('Starting ', func[i].__name__, 'at:', ctime())
        print(func[i](n))
        print(func[i].__name__, 'finished at:', ctime())

    print('\n***MULTIPILE THREADs')
    threads = []
    for i in nfuncs:
        t = MyThread(func[i], (n,), func[i].__name__)
        threads.append(t)
    for i in nfuncs:
        threads[i].start()
    for i in nfuncs:
        threads[i].join()
        print(threads[i].getResult())
    print('ALL DONE')
示例#27
0
def main():
    nfuncs = range(len(funcs))

    print '*** SINGLE THREAD'
    for i in nfuncs:
        print 'starting', funcs[i].__name__, 'at:', ctime()
        print funcs[i](n)
        print funcs[i].__name__, 'finished at:', ctime()

    print '\n***MULTIPLE THREADS'
    threads = list()
    for i in nfuncs:
        t = MyThread(funcs[i], (n, ), funcs[i].__name__)
        threads.append(t)
    for i in nfuncs:
        threads[i].start()
    for i in nfuncs:
        threads[i].join()
        print threads[i].getResult()

    print 'ALL DONE!'
示例#28
0
def main():
    nfuncs = range(len(funcs))
    print('*****单线程开始****')
    for i in nfuncs:
        print('starting %s at: %s' % (funcs[i].__name__, ctime()))
        print(funcs[i](n))
        print('end %s at%s' % (funcs[i].__name__, ctime()))

    print('mutiple threads')
    threads = []
    for i in nfuncs:
        t = MyThread(funcs[i], (n, ), funcs[i].__name__)
        threads.append(t)

    for i in nfuncs:
        threads[i].start()

    for i in nfuncs:
        threads[i].join()
        print(threads[i].getResult())
    print('all done')
示例#29
0
def main():
    nfuncs = range(len(funcs))

    print "*** Single Thread ***"
    for i in nfuncs:
        print "starting", funcs[i].__name__, "at:", ctime()
        print funcs[i](n)
        print funcs[i].__name__, " finished", "at:", ctime()

    print "*** Multiple Thread ***"
    threads = []
    for i in nfuncs:
        threads.append(
            MyThread(func=funcs[i], args=(n, ), name=funcs[i].__name__))

    for i in nfuncs:
        print "starting", funcs[i].__name__, "at:", ctime()
        threads[i].start()
    for i in nfuncs:
        threads[i].join()
        print funcs[i].__name__, " finished", "at:", ctime()
示例#30
0
def main():
    '''
    a=2
    print "a=%d" %a
    area_test(a)
    print "a now is a= %d" %a

    q=Queue(10);
    print "main q size %d" %q.qsize()
    queue_test(q)
    print "after function q size %d" %q.qsize()
    '''
    threads = []
    q = Queue(10)
    loop = 10
    for i in range(nfuncs):
        t = MyThread(funcs[i], (q, loop))
        threads.append(t)

    for i in range(nfuncs):
        threads[i].start()
    '''