diff --git a/generate.py b/generate.py index 88e8e66..5953fbf 100644 --- a/generate.py +++ b/generate.py @@ -132,6 +132,8 @@ def create_game_tree(imgs): root.left.left, root.left.right = Node(imgs[2], '', 2, 'lose'), Node(imgs[2], '', 2, 'right') root.right.left, root.right.right = Node(imgs[2], '', 2, 'lose'), Node(imgs[2], '', 2, 'right') + print("Creation completed.") + return root @@ -149,6 +151,8 @@ def __init__(self, img, val, level, state = None): def populate_tree(root, captions): # assume generate_text generates winning text + print("Population begun.") + gen = process_co_output(generate_text(captions)) root.caption, root.val = captions[0], gen[0] @@ -165,6 +169,10 @@ def populate_tree(root, captions): gen_remaining = process_co_output(generate_text_level_three(captions, gen_left_from_root[:2])) root.left.left.caption, root.left.left.val = captions[2], gen_remaining[2] + print('Population completed.') + + return True + # def _expand_tree(node, current_level, max_level): # if current_level == max_level: # return diff --git a/images/testingShard/bottom_left.jpg b/images/testingShard/bottom_left.jpg index d5e41be..337a36d 100644 Binary files a/images/testingShard/bottom_left.jpg and b/images/testingShard/bottom_left.jpg differ diff --git a/images/testingShard/bottom_right.jpg b/images/testingShard/bottom_right.jpg index 1e8d53e..bd96419 100644 Binary files a/images/testingShard/bottom_right.jpg and b/images/testingShard/bottom_right.jpg differ diff --git a/images/testingShard/top_left.jpg b/images/testingShard/top_left.jpg index 9fb0e1d..a4f8e28 100644 Binary files a/images/testingShard/top_left.jpg and b/images/testingShard/top_left.jpg differ diff --git a/images/testingShard/top_right.jpg b/images/testingShard/top_right.jpg index ba760a8..b0328a8 100644 Binary files a/images/testingShard/top_right.jpg and b/images/testingShard/top_right.jpg differ diff --git a/main.py b/main.py index 82a8201..e8d4312 100644 --- a/main.py +++ b/main.py @@ -3,14 +3,20 @@ import math from pacman import run_game from board import boards, test_board, randomize_board +from generate import create_game_tree, populate_tree, print_tree +from image_captioning import predict_step WIDTH = 900 HEIGHT = 950 +imgs = ['./images/biking.jpg', './images/monke.jpg', './images/rohan.jpeg'] +captions = predict_step(imgs) +root = None + if __name__ == "__main__": pygame.init() screen = pygame.display.set_mode((WIDTH, HEIGHT)) - pygame.display.set_caption("TwoPac") + pygame.display.set_caption("Two-Pac") font = pygame.font.Font(None, 36) clock = pygame.time.Clock() @@ -23,33 +29,37 @@ angle = 0 color = (255, 255, 255) thickness = 5 - - # Loading screen loop - loading = True - while loading: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - pygame.quit() - sys.exit() - - screen.fill((0, 0, 0)) - # Draw the circular loading icon - start_angle = math.radians(angle) - end_angle = math.radians(angle + 270) - pygame.draw.arc(screen, color, (center[0]-radius, center[1]-radius, radius*2, radius*2), start_angle, end_angle, thickness) + screen.fill((0, 0, 0)) + + # Draw the circular loading icon + # start_angle = math.radians(angle) + # end_angle = math.radians(angle + 270) + # pygame.draw.arc(screen, color, (center[0]-radius, center[1]-radius, radius*2, radius*2), start_angle, end_angle, thickness) + + padding = 30 + loading_text = font.render('Loading...', True, color) + text2 = font.render('Analyzing Imgaes...', True, color) + text3 = font.render('Extracting Memories...', True, color) + text_rect = loading_text.get_rect(center=(center[0], center[1] + radius - 10)) + screen.blit(loading_text, text_rect) + screen.blit(text2, text2.get_rect(center=(center[0], center[1] + radius + 20))) + screen.blit(text3, text3.get_rect(center=(center[0], center[1] + radius + 50))) + + pygame.display.flip() - padding = 30 - loading_text = font.render('Loading...', True, color) - text_rect = loading_text.get_rect(center=(center[0], center[1] + radius + 40)) - screen.blit(loading_text, text_rect) + root = create_game_tree(imgs) + loadingComplete = populate_tree(root, captions) - angle = (angle + 5) % 360 + # angle = (angle + 5) % 360 - pygame.display.flip() + # if pygame.time.get_ticks() - start_time > loading_duration: + # loadingComplete = True + # clock.tick(60) - if pygame.time.get_ticks() - start_time > loading_duration: - loading = False - clock.tick(60) + root = create_game_tree(imgs) + loadingComplete = populate_tree(root, captions) + + # print_tree(root) run_game() diff --git a/split-image.py b/split-image.py deleted file mode 100644 index f606e80..0000000 --- a/split-image.py +++ /dev/null @@ -1,40 +0,0 @@ -from PIL import Image -import os - -def split_image(image_path, destination_path, name): - image = Image.open(image_path) - folder_name = name - folder_path = os.path.join(destination_path, folder_name) - os.makedirs(folder_path, exist_ok=True) - - # Get dimensions - width, height = image.size - - # Calculate the size of each piece - half_width = width // 2 - half_height = height // 2 - - # Define the four pieces - top_left = (0, 0, half_width, half_height) - top_right = (half_width, 0, width, half_height) - bottom_left = (0, half_height, half_width, height) - bottom_right = (half_width, half_height, width, height) - - # Crop the image into four pieces - image_top_left = image.crop(top_left) - image_top_right = image.crop(top_right) - image_bottom_left = image.crop(bottom_left) - image_bottom_right = image.crop(bottom_right) - - image_top_left.save(os.path.join(folder_path, 'top_left.jpg')) - image_top_right.save(os.path.join(folder_path, 'top_right.jpg')) - image_bottom_left.save(os.path.join(folder_path, 'bottom_left.jpg')) - image_bottom_right.save(os.path.join(folder_path, 'bottom_right.jpg')) - - -if __name__ == '__main__': - image_path = "./images/biking.jpg" - destination_path = './images' - name = "biking" - - split_image(image_path, destination_path, name) \ No newline at end of file