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/RenderTextureSensorComponent.cs from AnnaMats/ppo-Pyramids-Training: direct link, hf CLI and curl.
- Browser
- Download file 4.07 kB
-
https://huggingface.co/AnnaMats/ppo-Pyramids-Training/resolve/main/com.unity.ml-agents/Runtime/Sensors/RenderTextureSensorComponent.cs
- Command line
-
hf download hf://AnnaMats/ppo-Pyramids-Training/com.unity.ml-agents/Runtime/Sensors/RenderTextureSensorComponent.cs
-
curl -L -o RenderTextureSensorComponent.cs https://huggingface.co/AnnaMats/ppo-Pyramids-Training/resolve/main/com.unity.ml-agents/Runtime/Sensors/RenderTextureSensorComponent.cs
4.07 kB
| using System; | |
| using UnityEngine; | |
| using UnityEngine.Serialization; | |
| namespace Unity.MLAgents.Sensors | |
| { | |
| /// <summary> | |
| /// Component that wraps a <see cref="RenderTextureSensor"/>. | |
| /// </summary> | |
| [] | |
| public class RenderTextureSensorComponent : SensorComponent, IDisposable | |
| { | |
| RenderTextureSensor m_Sensor; | |
| /// <summary> | |
| /// The [RenderTexture](https://docs.unity3d.com/ScriptReference/RenderTexture.html) instance | |
| /// that the associated <see cref="RenderTextureSensor"/> wraps. | |
| /// </summary> | |
| [] | |
| RenderTexture m_RenderTexture; | |
| /// <summary> | |
| /// Stores the [RenderTexture](https://docs.unity3d.com/ScriptReference/RenderTexture.html) | |
| /// associated with this sensor. | |
| /// </summary> | |
| public RenderTexture RenderTexture | |
| { | |
| get { return m_RenderTexture; } | |
| set { m_RenderTexture = value; } | |
| } | |
| [] | |
| string m_SensorName = "RenderTextureSensor"; | |
| /// <summary> | |
| /// Name of the generated <see cref="RenderTextureSensor"/>. | |
| /// 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; } | |
| } | |
| [] | |
| bool m_Grayscale; | |
| /// <summary> | |
| /// Whether the RenderTexture observation should be converted to grayscale or not. | |
| /// Note that changing this after the sensor is created has no effect. | |
| /// </summary> | |
| public bool Grayscale | |
| { | |
| get { return m_Grayscale; } | |
| set { m_Grayscale = value; } | |
| } | |
| [] | |
| [] | |
| [] | |
| int m_ObservationStacks = 1; | |
| [] | |
| SensorCompressionType m_Compression = SensorCompressionType.PNG; | |
| /// <summary> | |
| /// Compression type for the render texture observation. | |
| /// </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; } | |
| } | |
| /// <inheritdoc/> | |
| public override ISensor[] CreateSensors() | |
| { | |
| Dispose(); | |
| m_Sensor = new RenderTextureSensor(RenderTexture, Grayscale, SensorName, m_Compression); | |
| 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.CompressionType = m_Compression; | |
| } | |
| } | |
| /// <summary> | |
| /// Clean up the sensor created by CreateSensors(). | |
| /// </summary> | |
| public void Dispose() | |
| { | |
| if (!ReferenceEquals(null, m_Sensor)) | |
| { | |
| m_Sensor.Dispose(); | |
| m_Sensor = null; | |
| } | |
| } | |
| } | |
| } | |