Skip to content

Problem with visualizing img with OpenCV in utils.py #16

Description

@tom634

I run default script in the Windows 10 with:
test_multiprocessing(CustomEnv, CustomAgent, test_df, test_df_nomalized, num_worker = 16, visualize=True, (...)
im main.py.

When it comes to utils.py to line:
img = img.reshape(self.fig.canvas.get_width_height()[::-1] + (3,))
I have error:

Traceback (most recent call last):
  File "C:\Users\Tomek\anaconda3\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "c:\Users\Tomek\Documents\binance_bot\RL-Bitcoin-trading-bot-main_my_version\multiprocessing_env.py", line 35, in run
    self.env.render(self.visualize)
  File "c:\Users\Tomek\Documents\binance_bot\RL-Bitcoin-trading-bot-main_my_version\RL-Bitcoin-trading-bot_7.py", line 324, in render
    img = self.visualization.render(self.df.loc[self.current_step], self.net_worth, self.trades)
  File "c:\Users\Tomek\Documents\binance_bot\RL-Bitcoin-trading-bot-main_my_version\utils.py", line 231, in render
    img  = img.reshape(self.fig.canvas.get_width_height()[::-1] + (3,))
ValueError: cannot reshape array of size 15360000 into shape (800,1600,3)

Prints are following:

print("2", img, "len", len(img))
print("3", self.fig.canvas.get_width_height())
print("4", self.fig.canvas.get_width_height()[::-1])
2 [255 255 255 ... 255 255 255] len 15360000
3 (1600, 800)
4 (800, 1600)

What should I do? figsize is:

# figsize attribute allows us to specify the width and height of a figure in unit inches
fig = plt.figure(figsize=(16,8)) 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions