Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Flatland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sfwatergit
Flatland
Commits
3c61da9f
Commit
3c61da9f
authored
5 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
bug fix
parent
e02f332b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notebooks/Simple_Rendering_Demo.ipynb
+67
-15
67 additions, 15 deletions
notebooks/Simple_Rendering_Demo.ipynb
with
67 additions
and
15 deletions
notebooks/Simple_Rendering_Demo.ipynb
+
67
−
15
View file @
3c61da9f
...
@@ -9,9 +9,18 @@
...
@@ -9,9 +9,18 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
21
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"source": [
"%load_ext autoreload\n",
"%load_ext autoreload\n",
"%autoreload 2"
"%autoreload 2"
...
@@ -19,7 +28,7 @@
...
@@ -19,7 +28,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
22
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -31,7 +40,7 @@
...
@@ -31,7 +40,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
23
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -41,7 +50,7 @@
...
@@ -41,7 +50,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
24
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -53,9 +62,22 @@
...
@@ -53,9 +62,22 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
25
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/html": [
"<style>.container { width:90% !important; }</style>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"source": [
"from IPython.core.display import display, HTML\n",
"from IPython.core.display import display, HTML\n",
"display(HTML(\"<style>.container { width:90% !important; }</style>\"))"
"display(HTML(\"<style>.container { width:90% !important; }</style>\"))"
...
@@ -70,7 +92,7 @@
...
@@ -70,7 +92,7 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
26
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -92,28 +114,43 @@
...
@@ -92,28 +114,43 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
31
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
"oRT = rt.RenderTool(env,gl=\"PILSVG\")\n",
"oRT = rt.RenderTool(env,gl=\"PILSVG\")\n",
"env.dev_pred_dict = env.dev_obs_dict\n",
"env.dev_pred_dict = env.dev_obs_dict\n",
"oRT.render_env(show_observations=
Tru
e,show_predictions=True)\n",
"oRT.render_env(show_observations=
Fals
e,show_predictions=True)\n",
"img = oRT.get_image()"
"img = oRT.get_image()"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
32
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6a9401eacf31417d97119674cf249bc7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"source": [
"jpy_canvas.Canvas(img)"
"jpy_canvas.Canvas(img)"
]
]
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
29
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": [
"source": [
...
@@ -124,9 +161,24 @@
...
@@ -124,9 +161,24 @@
},
},
{
{
"cell_type": "code",
"cell_type": "code",
"execution_count":
null
,
"execution_count":
30
,
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "cedca754ea334df9b4678c1a29a4788e",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Canvas()"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"source": [
"jpy_canvas.Canvas(img)"
"jpy_canvas.Canvas(img)"
]
]
...
...
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Plot the Env and some trees
# Plot the Env and some trees
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
%
load_ext
autoreload
%
load_ext
autoreload
%
autoreload
2
%
autoreload
2
```
```
%% Output
The autoreload extension is already loaded. To reload it, use:
%reload_ext autoreload
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
jpy_canvas
import
jpy_canvas
import
random
import
random
import
time
import
time
import
sys
import
sys
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
# in case you need to tweak your PYTHONPATH...
# in case you need to tweak your PYTHONPATH...
sys
.
path
.
append
(
"
../flatland
"
)
sys
.
path
.
append
(
"
../flatland
"
)
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
import
flatland.core.env
import
flatland.core.env
import
flatland.utils.rendertools
as
rt
import
flatland.utils.rendertools
as
rt
from
flatland.envs.rail_env
import
RailEnv
,
random_rail_generator
from
flatland.envs.rail_env
import
RailEnv
,
random_rail_generator
from
flatland.envs.observations
import
TreeObsForRailEnv
from
flatland.envs.observations
import
TreeObsForRailEnv
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
from
IPython.core.display
import
display
,
HTML
from
IPython.core.display
import
display
,
HTML
display
(
HTML
(
"
<style>.container { width:90% !important; }</style>
"
))
display
(
HTML
(
"
<style>.container { width:90% !important; }</style>
"
))
```
```
%% Output
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Generate
# Generate
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
nAgents
=
3
nAgents
=
3
fnMethod
=
random_rail_generator
(
cell_type_relative_proportion
=
[
1
]
*
11
)
fnMethod
=
random_rail_generator
(
cell_type_relative_proportion
=
[
1
]
*
11
)
env
=
RailEnv
(
width
=
20
,
env
=
RailEnv
(
width
=
20
,
height
=
10
,
height
=
10
,
rail_generator
=
fnMethod
,
rail_generator
=
fnMethod
,
number_of_agents
=
nAgents
,
number_of_agents
=
nAgents
,
obs_builder_object
=
TreeObsForRailEnv
(
max_depth
=
2
))
obs_builder_object
=
TreeObsForRailEnv
(
max_depth
=
2
))
```
```
%% Cell type:markdown id: tags:
%% Cell type:markdown id: tags:
# Render
# Render
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
oRT
=
rt
.
RenderTool
(
env
,
gl
=
"
PILSVG
"
)
oRT
=
rt
.
RenderTool
(
env
,
gl
=
"
PILSVG
"
)
env
.
dev_pred_dict
=
env
.
dev_obs_dict
env
.
dev_pred_dict
=
env
.
dev_obs_dict
oRT
.
render_env
(
show_observations
=
Tru
e
,
show_predictions
=
True
)
oRT
.
render_env
(
show_observations
=
Fals
e
,
show_predictions
=
True
)
img
=
oRT
.
get_image
()
img
=
oRT
.
get_image
()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
jpy_canvas
.
Canvas
(
img
)
jpy_canvas
.
Canvas
(
img
)
```
```
%% Output
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
oRT
=
rt
.
RenderTool
(
env
,
gl
=
"
PIL
"
)
oRT
=
rt
.
RenderTool
(
env
,
gl
=
"
PIL
"
)
oRT
.
render_env
()
oRT
.
render_env
()
img
=
oRT
.
get_image
()
img
=
oRT
.
get_image
()
```
```
%% Cell type:code id: tags:
%% Cell type:code id: tags:
```
python
```
python
jpy_canvas
.
Canvas
(
img
)
jpy_canvas
.
Canvas
(
img
)
```
```
%% Output
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment