Reinforcement Learning
ml-agents
TensorBoard
ONNX
Pyramids
deep-reinforcement-learning
ML-Agents-Pyramids
Instructions to use AnnaMats/ppo-Pyramids-Training with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ml-agents
How to use AnnaMats/ppo-Pyramids-Training with ml-agents:
mlagents-load-from-hf --repo-id="AnnaMats/ppo-Pyramids-Training" --local-dir="./downloads"
- Notebooks
- Google Colab
- Kaggle
Download com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs from AnnaMats/ppo-Pyramids-Training: direct link, hf CLI and curl.
- Browser
- Download file 5.71 kB
-
https://huggingface.co/AnnaMats/ppo-Pyramids-Training/resolve/main/com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
- Command line
-
hf download hf://AnnaMats/ppo-Pyramids-Training/com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
-
curl -L -o CameraSensorComponent.cs https://huggingface.co/AnnaMats/ppo-Pyramids-Training/resolve/main/com.unity.ml-agents/Runtime/Sensors/CameraSensorComponent.cs
5.71 kB
| using System; | |
| using UnityEngine; | |
| using UnityEngine.Serialization; | |
| namespace Unity.MLAgents.Sensors | |
| { | |
| /// <summary> | |
| /// A SensorComponent that creates a <see cref="CameraSensor"/>. | |
| /// </summary> | |
| [] | |
| public class CameraSensorComponent : SensorComponent, IDisposable | |
| { | |
| [] | |
| Camera m_Camera; | |
| CameraSensor m_Sensor; | |
| /// <summary> | |
| /// Camera object that provides the data to the sensor. | |
| /// </summary> | |
| public Camera Camera | |
| { | |
| get { return m_Camera; } | |
| set { m_Camera = value; UpdateSensor(); } | |
| } | |
| [] | |
| string m_SensorName = "CameraSensor"; | |
| /// <summary> | |
| /// Name of the generated <see cref="CameraSensor"/> object. | |
| /// Note that changing this at runtime does not affect how the Agent sorts the sensors. | |
| /// </summary> | |
| public string SensorName | |
| { | |
| get { return m_SensorName; } | |
| set { m_SensorName = value; } | |
| } | |
| [] | |
| int m_Width = 84; | |
| /// <summary> | |
| /// Width of the generated observation. | |
| /// Note that changing this after the sensor is created has no effect. | |
| /// </summary> | |
| public int Width | |
| { | |
| get { return m_Width; } | |
| set { m_Width = value; } | |
| } | |
| [] | |
| int m_Height = 84; | |
| /// <summary> | |
| /// Height of the generated observation. | |
| /// Note that changing this after the sensor is created has no effect. | |
| /// </summary> | |
| public int Height | |
| { | |
| get { return m_Height; } | |
| set { m_Height = value; } | |
| } | |
| [] | |
| bool m_Grayscale; | |
| /// <summary> | |
| /// Whether to generate grayscale images or color. | |
| /// Note that changing this after the sensor is created has no effect. | |
| /// </summary> | |
| public bool Grayscale | |
| { | |
| get { return m_Grayscale; } | |
| set { m_Grayscale = value; } | |
| } | |
| [] | |
| ObservationType m_ObservationType; | |
| /// <summary> | |
| /// The type of the observation. | |
| /// </summary> | |
| public ObservationType ObservationType | |
| { | |
| get { return m_ObservationType; } | |
| set { m_ObservationType = value; UpdateSensor(); } | |
| } | |
| [] | |
| bool m_RuntimeCameraEnable; | |
| /// <summary> | |
| /// Controls the whether the camera sensor's attached camera | |
| /// is enabled during runtime. Overrides the camera object enabled status. | |
| /// Disabled for improved performance. Disabled by default. | |
| /// </summary> | |
| public bool RuntimeCameraEnable | |
| { | |
| get { return m_RuntimeCameraEnable; } | |
| set { m_RuntimeCameraEnable = value; UpdateSensor(); } | |
| } | |
| [] | |
| [] | |
| [] | |
| int m_ObservationStacks = 1; | |
| [] | |
| SensorCompressionType m_Compression = SensorCompressionType.PNG; | |
| /// <summary> | |
| /// The compression type to use for the sensor. | |
| /// </summary> | |
| public SensorCompressionType CompressionType | |
| { | |
| get { return m_Compression; } | |
| set { m_Compression = value; UpdateSensor(); } | |
| } | |
| /// <summary> | |
| /// Whether to stack previous observations. Using 1 means no previous observations. | |
| /// Note that changing this after the sensor is created has no effect. | |
| /// </summary> | |
| public int ObservationStacks | |
| { | |
| get { return m_ObservationStacks; } | |
| set { m_ObservationStacks = value; } | |
| } | |
| void Start() | |
| { | |
| UpdateSensor(); | |
| } | |
| /// <summary> | |
| /// Creates the <see cref="CameraSensor"/> | |
| /// </summary> | |
| /// <returns>The created <see cref="CameraSensor"/> object for this component.</returns> | |
| public override ISensor[] CreateSensors() | |
| { | |
| Dispose(); | |
| m_Sensor = new CameraSensor(m_Camera, m_Width, m_Height, Grayscale, m_SensorName, m_Compression, m_ObservationType); | |
| if (ObservationStacks != 1) | |
| { | |
| return new ISensor[] { new StackingSensor(m_Sensor, ObservationStacks) }; | |
| } | |
| return new ISensor[] { m_Sensor }; | |
| } | |
| /// <summary> | |
| /// Update fields that are safe to change on the Sensor at runtime. | |
| /// </summary> | |
| internal void UpdateSensor() | |
| { | |
| if (m_Sensor != null) | |
| { | |
| m_Sensor.Camera = m_Camera; | |
| m_Sensor.CompressionType = m_Compression; | |
| m_Sensor.Camera.enabled = m_RuntimeCameraEnable; | |
| } | |
| } | |
| /// <summary> | |
| /// Clean up the sensor created by CreateSensors(). | |
| /// </summary> | |
| public void Dispose() | |
| { | |
| if (!ReferenceEquals(m_Sensor, null)) | |
| { | |
| m_Sensor.Dispose(); | |
| m_Sensor = null; | |
| } | |
| } | |
| } | |
| } | |