Koshti10 commited on
Commit
4b6da58
·
verified ·
1 Parent(s): 56ba131

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +0 -2
  2. src/boards.py +9 -0
  3. src/utils.py +1 -1
app.py CHANGED
@@ -1,6 +1,4 @@
1
  import gradio as gr
2
- import numpy as np
3
- import plotly.graph_objects as go
4
 
5
  from src.utils import select_board
6
 
 
1
  import gradio as gr
 
 
2
 
3
  from src.utils import select_board
4
 
src/boards.py CHANGED
@@ -39,5 +39,14 @@ class GenerateBoard():
39
  image = env.render()
40
  image = Image.fromarray(image)
41
 
 
 
 
 
 
 
 
 
 
42
  return image, target_options, info
43
 
 
39
  image = env.render()
40
  image = Image.fromarray(image)
41
 
42
+ # Convert all white pixels to gray
43
+ image = image.convert("RGBA") # Ensure the image has an alpha channel
44
+ data = np.array(image) # Convert image to numpy array
45
+ # Create a mask for white pixels
46
+ white_pixels = (data[:, :, :3] == [255, 255, 255]).all(axis=2)
47
+ data[white_pixels] = [200, 200, 200, 20]
48
+
49
+ image = Image.fromarray(data) # Convert back to image
50
+
51
  return image, target_options, info
52
 
src/utils.py CHANGED
@@ -5,7 +5,7 @@ def select_board(level: str = 'easy', size: int = 18, board_number: int = 0):
5
  initial_board_image, target_positions, info = GenerateBoard(level, size, board_number).setup_initial_board()
6
 
7
  # Convert initial_board_image to a Plotly figure
8
- fig = px.imshow(initial_board_image) # Use Plotly's imshow
9
  fig.update_xaxes(showticklabels=False) # Hide x-axis ticks
10
  fig.update_yaxes(showticklabels=False) # Hide y-axis ticks
11
 
 
5
  initial_board_image, target_positions, info = GenerateBoard(level, size, board_number).setup_initial_board()
6
 
7
  # Convert initial_board_image to a Plotly figure
8
+ fig = px.imshow(initial_board_image) # Use Plotly's imshow with gray scale
9
  fig.update_xaxes(showticklabels=False) # Hide x-axis ticks
10
  fig.update_yaxes(showticklabels=False) # Hide y-axis ticks
11