Exemplo n.º 1
0
    def toolkit_section(self):

        title = tk.Frame(self.toolkit)
        title.grid(row=0, column=0, columnspan=2, pady=10)

        Label(
            title,
            text="PATH-FINDER",
            size=24
        ).pack(fill=tk.X)

        Label(
            self.toolkit,
            text="Maze Generation",
            size=14
        ).grid(row=1, column=0, padx=10, pady=10, sticky='W')

        Button(
            self.toolkit,
            text="Generate Maze",
            command=lambda: self.grid.generate_maze(
                self.visualize_maze.get(), 
                self.perfect_maze.get() + 1
            )
        ).grid(row=2, column=0, padx=10, pady=5, sticky='WE')

        Checkbutton(
            self.toolkit,
            variable=self.visualize_maze,
            text="Visualize",
        ).grid(row=2, column=1, padx=10, pady=5, sticky='W')

        Button(
            self.toolkit,
            text="Clear Maze",
            command=self.grid.reset
        ).grid(row=3, column=0, padx=10,pady=5, sticky='WE')

        Checkbutton(
            self.toolkit,
            text="Perfect Maze\n(Only 1 soultion)",
            variable=self.perfect_maze,
        ).grid(row=3, column=1, padx=10, pady=5, sticky='W')

        Label(
            self.toolkit,
            text="Path Finding",
            size=14
        ).grid(row=5, column=0, padx=10, pady=10, sticky='W')

        Button(
            self.toolkit,
            text="Find Path",
            command=lambda: a_star(self.grid),
        ).grid(row=6, column=0, columnspan=2, padx=10,pady=5, sticky='WE')
Exemplo n.º 2
0
def load_images_and_labels(root_data_path):
    hot_dog_paths, not_hot_dog_paths = load_data_paths(root_data_path)
    hot_dog_labels, not_hot_dog_labels = create_labels(hot_dog_paths,
                                                       not_hot_dog_paths)

    images = [Image(path) for path in hot_dog_paths + not_hot_dog_paths]
    labels = [Label(value) for value in hot_dog_labels + not_hot_dog_labels]
    return images, labels
Exemplo n.º 3
0
 def loading_page(self):
     self.win.fill((0, 0, 0))
     loading = Label('Finding Player...')
     loading.config(color=(255, 255, 255), font_size=40)
     rect = loading.get_rect()
     rect.center = 500, 320
     loading.draw(self.win, rect.x, rect.y)
     pg.display.update()
Exemplo n.º 4
0
import os.path as osp
import tensorflow as tf
import os
import bbox
import cv2
import numpy as np
from voc_eval import APCalculate
import argparse
from tqdm import tqdm
from ssd_network import SSD
from dataset import Dataset
from utils import Label
from collections import defaultdict

label_defs = {'VOC':(
    Label('dog', (30, 170, 250)),
    Label('sofa', (142, 0, 0)),
    Label('chair', (153, 153, 190)),
    Label('boat', (128,  64, 128)),
    Label('bicycle', (0, 74, 111)),
    Label('car', ( 70,  70,  70)),
    Label('pottedplant', (180, 130, 70)),
    Label('horse', (0, 220, 220)),
    Label('cow', (90, 120, 150)),
    Label('person', ( 52, 151,  52)),
    Label('diningtable', (153, 153, 153)),
    Label('bottle', (232, 35, 244)),
    Label('cat', (156, 102, 102)),
    Label('bird', (81, 0, 81)),
    Label('train', (230, 0, 0)),
    Label('motorbike', (35, 142, 107)),
    # Label('bus',         rgb2bgr((230, 150, 140))),
    # Label('car',         rgb2bgr(( 70,  70,  70))),
    # Label('cat',         rgb2bgr((102, 102, 156))),
    # Label('chair',       rgb2bgr((190, 153, 153))),
    # Label('cow',         rgb2bgr((150, 120,  90))),
    # Label('diningtable', rgb2bgr((153, 153, 153))),
    # Label('dog',         rgb2bgr((250, 170,  30))),
    # Label('horse',       rgb2bgr((220, 220,   0))),
    # Label('motorbike',   rgb2bgr((107, 142,  35))),
    # Label('person',      rgb2bgr(( 52, 151,  52)))
    # Label('pottedplant', rgb2bgr(( 70, 130, 180))),
    # Label('sheep',       rgb2bgr((220,  20,  60))),
    # Label('sofa',        rgb2bgr((  0,   0, 142))),
    # Label('train',       rgb2bgr((  0,   0, 230))),
    # Label('tvmonitor',   rgb2bgr((119,  11,  32)))
    Label('face', rgb2bgr((255,0,0)))
    ]

#-------------------------------------------------------------------------------
class PascalVOCSource:
    #---------------------------------------------------------------------------
    def __init__(self):
        self.num_classes   = len(label_defs)
        self.colors        = {l.name: l.color for l in label_defs}
        self.lid2name      = {i: l.name for i, l in enumerate(label_defs)}
        self.lname2id      = {l.name: i for i, l in enumerate(label_defs)}
        self.num_train     = 0
        self.num_valid     = 0
        self.num_test      = 0
        self.train_samples = []
        self.valid_samples = []
Exemplo n.º 6
0
import math
import cv2
import os

import numpy as np

from utils import Label, Box, Sample, Size
from utils import rgb2bgr, abs2prop
from glob import glob
from tqdm import tqdm

#-------------------------------------------------------------------------------
# Labels
#-------------------------------------------------------------------------------
label_defs = [
    Label('aeroplane', rgb2bgr((0, 0, 0))),
    Label('bicycle', rgb2bgr((111, 74, 0))),
    Label('bird', rgb2bgr((81, 0, 81))),
    Label('boat', rgb2bgr((128, 64, 128))),
    Label('bottle', rgb2bgr((244, 35, 232))),
    Label('bus', rgb2bgr((230, 150, 140))),
    Label('car', rgb2bgr((70, 70, 70))),
    Label('cat', rgb2bgr((102, 102, 156))),
    Label('chair', rgb2bgr((190, 153, 153))),
    Label('cow', rgb2bgr((150, 120, 90))),
    Label('diningtable', rgb2bgr((153, 153, 153))),
    Label('dog', rgb2bgr((250, 170, 30))),
    Label('horse', rgb2bgr((220, 220, 0))),
    Label('motorbike', rgb2bgr((107, 142, 35))),
    Label('person', rgb2bgr((52, 151, 52))),
    Label('pottedplant', rgb2bgr((70, 130, 180))),
Exemplo n.º 7
0
from glob import glob
from tqdm import tqdm

#-------------------------------------------------------------------------------
# Labels
#-------------------------------------------------------------------------------
actions = [
    'Basketball', 'BasketballDunk', 'Biking', 'CliffDiving', 'CricketBowling',
    'Diving', 'Fencing', 'FloorGymnastics', 'GolfSwing', 'HorseRiding',
    'IceDancing', 'LongJump', 'PoleVault', 'RopeClimbing', 'SalsaSpin',
    'SkateBoarding', 'Skiing', 'Skijet', 'SoccerJuggling', 'Surfing',
    'TennisSwing', 'TrampolineJumping', 'VolleyballSpiking', 'WalkingWithDog'
]

label_defs = [
    Label('Basketball', rgb2bgr((0, 0, 0))),
    Label('BasketballDunk', rgb2bgr((111, 74, 0))),
    Label('Biking', rgb2bgr((81, 0, 81))),
    Label('CliffDiving', rgb2bgr((128, 64, 128))),
    Label('CricketBowling', rgb2bgr((244, 35, 232))),
    Label('Diving', rgb2bgr((230, 150, 140))),
    Label('Fencing', rgb2bgr((70, 70, 70))),
    Label('FloorGymnastics', rgb2bgr((102, 102, 156))),
    Label('GolfSwing', rgb2bgr((190, 153, 153))),
    Label('HorseRiding', rgb2bgr((150, 120, 90))),
    Label('IceDancing', rgb2bgr((153, 153, 153))),
    Label('LongJump', rgb2bgr((250, 170, 30))),
    Label('PoleVault', rgb2bgr((220, 220, 0))),
    Label('RopeClimbing', rgb2bgr((107, 142, 35))),
    Label('SalsaSpin', rgb2bgr((52, 151, 52))),
    Label('SkateBoarding', rgb2bgr((70, 130, 180))),
Exemplo n.º 8
0
import os
import imageio

import numpy as np

from utils import Label, Box, Sample, Size
from utils import rgb2bgr, abs2prop
from glob import glob
from tqdm import tqdm

#-------------------------------------------------------------------------------
# Labels
#-------------------------------------------------------------------------------
label_defs = [
    #Label('aeroplane',   rgb2bgr((1,     0,   0))),
    Label('tumor', rgb2bgr((0, 0, 0))),
    # Label('bicycle',     rgb2bgr((111,  74,   0))),
    # Label('bird',        rgb2bgr(( 81,   0,  81))),
    # Label('boat',        rgb2bgr((128,  64, 128))),
    # Label('bottle',      rgb2bgr((244,  35, 232))),
    # Label('bus',         rgb2bgr((230, 150, 140))),
    # Label('car',         rgb2bgr(( 70,  70,  70))),
    # Label('cat',         rgb2bgr((102, 102, 156))),
    # Label('chair',       rgb2bgr((190, 153, 153))),
    # Label('cow',         rgb2bgr((150, 120,  90))),
    # Label('diningtable', rgb2bgr((153, 153, 153))),
    # Label('dog',         rgb2bgr((250, 170,  30))),
    # Label('horse',       rgb2bgr((220, 220,   0))),
    # Label('motorbike',   rgb2bgr((107, 142,  35))),
    # Label('person',      rgb2bgr(( 52, 151,  52))),
    # Label('pottedplant', rgb2bgr(( 70, 130, 180))),
Exemplo n.º 9
0
import math
import cv2
import os

import numpy as np

from utils import Label, Box, Sample, Size
from utils import rgb2bgr, abs2prop
from glob import glob
from tqdm import tqdm

#-------------------------------------------------------------------------------
# Labels
#-------------------------------------------------------------------------------
label_defs = [
    Label('hand', rgb2bgr((0, 0, 0)))
]

#-------------------------------------------------------------------------------


class PascalVOCSource:
    #---------------------------------------------------------------------------
    def __init__(self):
        self.num_classes = len(label_defs)
        self.colors = {l.name: l.color for l in label_defs}
        self.lid2name = {i: l.name for i, l in enumerate(label_defs)}
        self.lname2id = {l.name: i for i, l in enumerate(label_defs)}
        self.num_train = 0
        self.num_valid = 0
        self.num_test = 0
Exemplo n.º 10
0
    def game_page(self, online=False):

        self.loading_page()

        self.win.fill((255, 0, 0))

        bg = pg.image.load('./assets/board.jpg')
        bg = pg.transform.scale(bg, (680, self.win_height))

        computer = Label('Computer')
        computer.config(color=(57, 62, 70), font_size=54)

        user = Label('User')
        user.config(color=(240, 240, 240), font_size=54)

        black_timer = Label('Black')
        black_timer.config(color=(57, 62, 70), font_size=48)

        black_time = Label('15:00')
        black_time.config(color=(57, 62, 70), font_size=32)

        white_timer = Label('White')
        white_timer.config(color=(240, 240, 240), font_size=48)

        white_time = Label('15:00')
        white_time.config(color=(240, 240, 240), font_size=32)

        player = Network()

        board = Board()
        player_turn = 1

        if online:
            player.connect()
            color = player.recv(13)

            player_turn = 1 if color == 'w' else 0

        message1 = Label('')
        message1.config(color=(255, 255, 255), font_size=48)

        message2 = Label('')
        message2.config(color=(255, 255, 255), font_size=32)

        w_time = b_time = 900

        while True:

            if online and not board.game_over:
                board = player.get_board()
                if board.turn == 1:
                    w_time = 900 - board.white_time_elapsed
                else:
                    b_time = 900 - board.black_time_elapsed

            self.win.blit(bg, (0, 0))

            pg.draw.rect(self.win, (1, 1, 1), (690, 0, 310, 680))

            if online:
                black_timer.draw(self.win, 780, 20)
                black_time.change_text(
                    f'{b_time // 60}:{ f"0{b_time % 60}" if b_time % 60 < 10 else b_time % 60}'
                )
                black_time.draw(self.win, 800, 100)
            else:
                computer.draw(self.win, 750, 20)

            pg.draw.rect(self.win, (255, 0, 0),
                         (690, 150, 310, 10))  # Red Line

            board_message1 = message1.get_rect()
            board_message1.center = (680 + 160, 200)
            message1.draw(self.win, board_message1.x, board_message1.y)

            board_message2 = message2.get_rect()
            board_message2.center = (680 + 160, 250)
            message2.draw(self.win, board_message2.x, board_message2.y)

            pg.draw.rect(self.win, (255, 0, 0),
                         (690, 530, 310, 10))  # Red Line

            if online:
                white_timer.draw(self.win, 780, 550)
                white_time.change_text(
                    f'{w_time // 60}:{ f"0{w_time % 60}" if w_time % 60 < 10 else w_time % 60}'
                )
                white_time.draw(self.win, 800, 630)
            else:
                user.draw(self.win, 790, 550)

            if not online and not board.turn:
                self.call_ai(board)

            for event in pg.event.get():
                if event.type == pg.QUIT:
                    self.quit()

                if event.type == pg.KEYDOWN:
                    if event.key == pg.K_q:
                        if online:
                            player.disconnect()
                        self.menu_page()

                if event.type == pg.MOUSEBUTTONDOWN:
                    mx, my = event.pos
                    if board.turn == player_turn and not board.game_over:
                        board.select(mx // 85, my // 85)

                        if online:
                            player.send_board(board)

            self.draw(board)

            for i in range(len(board.history)):
                turn, source, dest = board.history[i]
                source = self.get_square(*source)
                dest = self.get_square(*dest)

                history = Label(f'{source}-{dest}')
                history.config(color=(240, 240, 240) if turn == 1 else
                               (57, 62, 70),
                               font_size=24)
                history.draw(self.win, 810, 280 + (i * 40))

            if w_time == 0 or b_time == 0:
                board.game_over = True
                message1.change_text("Time's Up")
                message2.change_text(
                    f'{"Black" if board.turn == 1 else "White"} Wins')
                if online:
                    player.disconnect()
            elif board.game_over and board.check_mate:
                message1.change_text('Check Mate')
                message2.change_text(
                    f'{"Black" if board.turn == 1 else "White"} Wins')
                if online:
                    player.disconnect()
            elif board.game_over:
                message2.change_text('Other Player Left')
                if online:
                    player.disconnect()
            elif board.check:
                message1.change_text('Check')
            else:
                message1.change_text('')
                message2.change_text('')

            pg.display.update()