MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / png_bytes_to_numpy

Function png_bytes_to_numpy

webarena/browser_env/utils.py:16–24  ·  view source on GitHub ↗

Convert png bytes to numpy array Example: >>> fig = go.Figure(go.Scatter(x=[1], y=[1])) >>> plt.imshow(png_bytes_to_numpy(fig.to_image('png')))

(png: bytes)

Source from the content-addressed store, hash-verified

14
15
16def png_bytes_to_numpy(png: bytes) -> npt.NDArray[np.uint8]:
17 """Convert png bytes to numpy array
18
19 Example:
20
21 >>> fig = go.Figure(go.Scatter(x=[1], y=[1]))
22 >>> plt.imshow(png_bytes_to_numpy(fig.to_image('png')))
23 """
24 return np.array(Image.open(BytesIO(png)))
25
26
27class AccessibilityTreeNode(TypedDict):

Callers 3

processMethod · 0.85
aresetMethod · 0.85
astepMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected