Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove matplotlib from conda requirements. #2520

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions conda-build/habitat-sim/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ requirements:
- tqdm
- imageio
- imageio-ffmpeg
- matplotlib
- libglu # [linux]
- libxcb # [linux]
- xorg-libx11 # [linux]
Expand All @@ -69,7 +68,7 @@ requirements:
- scipy>=1.3.0
- tqdm
- imageio
- matplotlib
- imageio-ffmpeg
- libxcb # [linux]
- xorg-libx11 # [linux]
- xorg-libxau # [linux]
Expand Down
21 changes: 9 additions & 12 deletions examples/tutorials/lighting_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import magnum as mn
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image

import habitat_sim
from habitat_sim.gfx import LightInfo, LightPositionModel
Expand All @@ -22,20 +22,17 @@


def show_img(data, save):
plt.figure(figsize=(12, 12))
plt.imshow(data, interpolation="nearest")
plt.axis("off")
plt.show(block=False)
# Convert the data to a PIL Image
img = Image.fromarray((data).astype(np.uint8))
# Convert to RGB if the image has an alpha channel
if img.mode == "RGBA":
img = img.convert("RGB")
# Display the image
img.show()
if save:
global save_index
plt.savefig(
output_path + str(save_index) + ".jpg",
bbox_inches="tight",
pad_inches=0,
quality=50,
)
img.save(output_path + str(save_index) + ".jpg", quality=50)
save_index += 1
plt.pause(1)


def get_obs(sim, show, save):
Expand Down
8 changes: 4 additions & 4 deletions examples/tutorials/nb_python/ECCV_2020_Advanced_Features.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ def restore_camera_track_config(sim, init_state):
visual_sensor._spec.position = init_state["position"]
visual_sensor._spec.orientation = init_state["orientation"]
visual_sensor._sensor_object.set_transformation_from_spec()
# restore the agent's state to what was savedd in init_camera_track_config
# restore the agent's state to what was saved in init_camera_track_config
sim.get_agent(agent_ID).set_state(init_state["agent_state"])


Expand Down Expand Up @@ -1016,7 +1016,7 @@ def get_2d_point(sim, sensor_name, point_3d):
make_simulator_from_settings(sim_settings)

# fmt: off
# @markdown In this example, we load a box asset with each face as a separate component with its own SceneNode. We demonstrate the result of modiyfing the associated semantic ids via object templates, the Simulator API, and the SceneNode property.
# @markdown In this example, we load a box asset with each face as a separate component with its own SceneNode. We demonstrate the result of modifying the associated semantic ids via object templates, the Simulator API, and the SceneNode property.
# fmt: on

rigid_obj_mgr.remove_all_objects()
Expand Down Expand Up @@ -1262,7 +1262,7 @@ def get_2d_point(sim, sensor_name, point_3d):
force_flat_shading = True # @param {type:"boolean"}
new_template.force_flat_shading = force_flat_shading

# @markdown The x,y,z components of the intertia matrix diagonal
# @markdown The x,y,z components of the inertia matrix diagonal

inertia_X = 1.0 # @param {type:"slider", min:0.1, max:10, step:0.1}
inertia_Y = 1 # @param {type:"slider", min:0.1, max:10, step:0.1}
Expand Down Expand Up @@ -1398,7 +1398,7 @@ def get_2d_point(sim, sensor_name, point_3d):
# @markdown Note 4 : There often are different modifiable properties available for solid and wireframe versions of the same primitive.

# @markdown ###Primitive Asset Template Properties
# @markdown The flollowing examples will illustrate all the modifiable properties for each of the different types of primitives, and allow for their synthesis.
# @markdown The following examples will illustrate all the modifiable properties for each of the different types of primitives, and allow for their synthesis.


# Primitive Asset Attributes Manager, provides access to AssetAttributesTemplates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
" visual_sensor._spec.position = init_state[\"position\"]\n",
" visual_sensor._spec.orientation = init_state[\"orientation\"]\n",
" visual_sensor._sensor_object.set_transformation_from_spec()\n",
" # restore the agent's state to what was savedd in init_camera_track_config\n",
" # restore the agent's state to what was saved in init_camera_track_config\n",
" sim.get_agent(agent_ID).set_state(init_state[\"agent_state\"])\n",
"\n",
"\n",
Expand Down Expand Up @@ -1080,7 +1080,7 @@
"make_simulator_from_settings(sim_settings)\n",
"\n",
"# fmt: off\n",
"# @markdown In this example, we load a box asset with each face as a separate component with its own SceneNode. We demonstrate the result of modiyfing the associated semantic ids via object templates, the Simulator API, and the SceneNode property.\n",
"# @markdown In this example, we load a box asset with each face as a separate component with its own SceneNode. We demonstrate the result of modifying the associated semantic ids via object templates, the Simulator API, and the SceneNode property.\n",
"# fmt: on\n",
"\n",
"rigid_obj_mgr.remove_all_objects()\n",
Expand Down Expand Up @@ -1363,7 +1363,7 @@
"force_flat_shading = True # @param {type:\"boolean\"}\n",
"new_template.force_flat_shading = force_flat_shading\n",
"\n",
"# @markdown The x,y,z components of the intertia matrix diagonal\n",
"# @markdown The x,y,z components of the inertia matrix diagonal\n",
"\n",
"inertia_X = 1.0 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\n",
"inertia_Y = 1 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\n",
Expand Down Expand Up @@ -1522,7 +1522,7 @@
"# @markdown Note 4 : There often are different modifiable properties available for solid and wireframe versions of the same primitive.\n",
"\n",
"# @markdown ###Primitive Asset Template Properties\n",
"# @markdown The flollowing examples will illustrate all the modifiable properties for each of the different types of primitives, and allow for their synthesis.\n",
"# @markdown The following examples will illustrate all the modifiable properties for each of the different types of primitives, and allow for their synthesis.\n",
"\n",
"\n",
"# Primitive Asset Attributes Manager, provides access to AssetAttributesTemplates\n",
Expand Down
53 changes: 35 additions & 18 deletions examples/tutorials/semantic_id_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import magnum as mn
import numpy as np
from matplotlib import pyplot as plt
from PIL import Image

import habitat_sim
from habitat_sim.utils.common import quat_from_angle_axis
Expand All @@ -20,27 +20,44 @@
save_index = 0


def apply_colormap(image):
# Normalize the uint32 image to the range [0, 255]
normalized = (image - image.min()) / (image.max() - image.min()) * 255
normalized = normalized.astype(np.uint8)

# Create a color map
colormap = np.zeros((256, 3), dtype=np.uint8)
for i in range(256):
colormap[i] = [i, 255 - i, (i // 2) % 256]

# Apply the colormap
colorized = colormap[normalized]
return Image.fromarray(colorized)


def show_img(data, save):
# display rgb and semantic images side-by-side
fig = plt.figure(figsize=(12, 12))
ax1 = fig.add_subplot(1, 2, 1)
ax1.axis("off")
ax1.imshow(data[0], interpolation="nearest")
ax2 = fig.add_subplot(1, 2, 2)
ax2.axis("off")
ax2.imshow(data[1], interpolation="nearest")
plt.axis("off")
plt.show(block=False)
# Convert numpy arrays to PIL Images
img1 = Image.fromarray(data[0])

# Color-code the semantic map (uint32) to visualize the semantic IDs
img2 = apply_colormap(data[1])

# Create a new image with twice the width to place images side-by-side
total_width = img1.width + img2.width
max_height = max(img1.height, img2.height)
new_img = Image.new("RGB", (total_width, max_height))

# Paste the images side-by-side
new_img.paste(img1, (0, 0))
new_img.paste(img2, (img1.width, 0))

# Display the combined image
new_img.show()

if save:
global save_index
plt.savefig(
output_path + str(save_index) + ".jpg",
bbox_inches="tight",
pad_inches=0,
quality=50,
)
new_img.save(output_path + str(save_index) + ".jpg", quality=50)
save_index += 1
plt.pause(1)


def get_obs(sim, show, save):
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ attrs>=19.1.0
gitpython
imageio
imageio-ffmpeg
matplotlib
numba
numpy==1.26.4
numpy-quaternion
Expand Down
Loading