Comments (4)
@Bailey-24
I modify the discrete observation environment (pct_envs/PctDiscrete0)/bin3D.py) by adding render() like this;
def render(self, mode=None, wait_time=10):
# mode is ignored
vis_plain = self.space.plain
# Create the image from the array
image = np.empty((len(vis_plain), len(vis_plain[0]), 3), dtype=np.uint8) # Create an empty image with 3 channels (RGB)
for i in range(len(vis_plain)):
for j in range(len(vis_plain[0])):
image[i][j] = self.colors_map[vis_plain[i][j]] # Set the pixel color based on the value in the array
# Resize the image
expanded_image = cv2.resize(image, (30*image.shape[1], 30*image.shape[0]), interpolation=cv2.INTER_NEAREST)
# Write the values on each cell
font = cv2.FONT_HERSHEY_SIMPLEX # Define the font
font_scale = 0.5 # Define the font scale
thickness = 1 # Define the line thickness
for i in range(len(vis_plain)):
for j in range(len(vis_plain[0])):
value = str(vis_plain[i][j]) # Convert the value to a string
(x, y) = (j * 30 + 5, i * 30 + 20) # Calculate the position of the text
cv2.putText(expanded_image, value, (x, y), font, font_scale, (0, 0, 0), thickness, cv2.LINE_AA)
# Display the image
cv2.imshow('Bin packing view', expanded_image)
cv2.waitKey(wait_time)
`
from online-3d-bpp-pct.
Hi, there is a bug.
AttributeError: 'PackingDiscrete' object has no attribute 'colors_map'
how do you initial and process the colors_map
in the env.
Thanks in advance.
from online-3d-bpp-pct.
@Bailey-24
Hi i'm afraid that i forgot the colors_map
in the PackingDiscrete
, I also added the colors_map
on the last line def __init__()
``
class PackingDiscrete(gym.Env):
def __init__(self,
setting,
container_size=(10, 10, 10),
item_set=None, data_name=None, load_test_data=False,
internal_node_holder=80, leaf_node_holder=50, next_holder=1, shuffle=False,
LNES = 'EMS',
**kwags):
self.internal_node_holder = internal_node_holder
self.leaf_node_holder = leaf_node_holder
self.next_holder = next_holder
self.shuffle = shuffle
self.bin_size = container_size
self.size_minimum = np.min(np.array(item_set))
self.setting = setting
self.item_set = item_set
if self.setting == 2: self.orientation = 6
else: self.orientation = 2
# The class that maintains the contents of the bin.
self.space = Space(*self.bin_size, self.size_minimum, self.internal_node_holder)
# Generator for train/test data
if not load_test_data:
assert item_set is not None
self.box_creator = RandomBoxCreator(item_set)
assert isinstance(self.box_creator, BoxCreator)
if load_test_data:
self.box_creator = LoadBoxCreator(data_name)
self.test = load_test_data
self.observation_space = gym.spaces.Box(low=0.0, high=self.space.height,
shape=((self.internal_node_holder + self.leaf_node_holder + self.next_holder) * 9,))
self.action_space = None
self.next_box_vec = np.zeros((self.next_holder, 9))
self.LNES = LNES # Leaf Node Expansion Schemes: EMS (recommend), EV, EP, CP, FC
# Define the color map
# Define the data type as 8-bit unsigned integer
self.colors_map = np.array([[20*vidx, 0, 255-20*vidx] for vidx in reversed(range(11))], dtype=np.uint8)
`
from online-3d-bpp-pct.
from online-3d-bpp-pct.
Related Issues (20)
- How to modify "internal nodes" to update the stacking space? HOT 2
- Is it possible to add "preview" (like bpp-k) to the code? HOT 4
- KeyError: 'PctDiscrete-v0' HOT 5
- Struggling to achieve the same performance in the discrete and continuous environment HOT 2
- mask_logits in AttentionModel is set to False by default HOT 1
- AssertionError: You must specify a action space HOT 3
- about performance in the continuous environment HOT 1
- leaf node generation for real-world experiments HOT 3
- Usage in real-world HOT 1
- How to get the 3D visualization? HOT 2
- An error occurs if x and y in container size is too large HOT 2
- The pretrained models run had no effect HOT 3
- What are the main factors that affect the training effect?
- About env PctDiscrete0
- ValueError: cannot find context for 'fork' HOT 8
- AssertionError HOT 8
- Online learning or Offline learning HOT 2
- AttributeError: 'PackingDiscrete' object has no attribute 'action_space' HOT 1
- The network structure HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from online-3d-bpp-pct.