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

Function png_bytes_to_numpy

eval_heldout/webarena/browser_env/utils.py:18–26  ·  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

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

Callers 3

processMethod · 0.85
aresetMethod · 0.85
astepMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected