Skip to content

Commit

Permalink
working v1
Browse files Browse the repository at this point in the history
  • Loading branch information
whyismynamerudy committed Jan 27, 2024
1 parent 8bc945a commit 207d17f
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 64 deletions.
8 changes: 8 additions & 0 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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]
Expand All @@ -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
Expand Down
Binary file modified images/testingShard/bottom_left.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/testingShard/bottom_right.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/testingShard/top_left.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/testingShard/top_right.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 34 additions & 24 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
40 changes: 0 additions & 40 deletions split-image.py

This file was deleted.

0 comments on commit 207d17f

Please sign in to comment.