Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Add Binder Link #16

Open
wants to merge 4 commits into
base: master
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dash-canvas
# dash-canvas [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/plotly/dash-canvas/master?urlpath=apps%2Fbinder%2Fcorrect_segmentation.ipynb)

dash-canvas is a package for image processing with
[Dash](https://dash.plot.ly/). It provides a Dash component for
Expand Down
165 changes: 165 additions & 0 deletions binder/correct_segmentation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Segmentation Correction App\n",
"Here we show a simple segmentation correction app using the [dash-canvas](https://github.com/plotly/dash-canvas) tool."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from IPython import display\n",
"import os\n",
"def show_app(app, port = 9999, \n",
" width = \"100%\", \n",
" height = \"900px\", \n",
" offline = False,\n",
" in_binder = None):\n",
" in_binder ='JUPYTERHUB_SERVICE_PREFIX' in os.environ if in_binder is None else in_binder\n",
" if in_binder:\n",
" base_prefix = '{}proxy/{}/'.format(os.environ['JUPYTERHUB_SERVICE_PREFIX'], port)\n",
" url = 'https://hub.mybinder.org{}'.format(base_prefix)\n",
" app.config.requests_pathname_prefix = base_prefix\n",
" else:\n",
" url = 'http://localhost:%d' % port\n",
" \n",
" iframe = '<a href=\"{url}\" target=\"_new\">Open in new window</a><hr><iframe src=\"{url}\" width={width} height={height}></iframe>'.format(url = url, \n",
" width = width, \n",
" height = height)\n",
" \n",
" display.display_html(iframe, raw = True)\n",
" if offline:\n",
" app.css.config.serve_locally = True\n",
" app.scripts.config.serve_locally = True\n",
" return app.run_server(debug=False, # needs to be false in Jupyter\n",
" host = '0.0.0.0',\n",
" port=port)\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os, sys\n",
"sys.path.append('..')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/srv/conda/lib/python3.6/site-packages/skimage/util/dtype.py:141: UserWarning:\n",
"\n",
"Possible precision loss when converting from float64 to uint8\n",
"\n"
]
}
],
"source": [
"import dash\n",
"import app2_correct_segmentation as cs"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<a href=\"https://hub.mybinder.org/user/kmader-dash-canvas-ivyrnudq/proxy/9999/\" target=\"_new\">Open in new window</a><hr><iframe src=\"https://hub.mybinder.org/user/kmader-dash-canvas-ivyrnudq/proxy/9999/\" width=100% height=900px></iframe>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" * Serving Flask app \"CorrectSegmentation\" (lazy loading)\n",
" * Environment: production\n",
" WARNING: Do not use the development server in a production environment.\n",
" Use a production WSGI server instead.\n",
" * Debug mode: off\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" * Running on http://0.0.0.0:9999/ (Press CTRL+C to quit)\n",
"127.0.0.1 - - [02/Apr/2019 16:51:10] \"GET / HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:51:10] \"GET /_dash-dependencies HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:51:10] \"GET /_dash-layout HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:51:11] \"POST /_dash-update-component HTTP/1.1\" 200 -\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"updating\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"127.0.0.1 - - [02/Apr/2019 16:51:11] \"POST /_dash-update-component HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:51:12] \"POST /_dash-update-component HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:51:12] \"POST /_dash-update-component HTTP/1.1\" 200 -\n"
]
}
],
"source": [
"app = dash.Dash('CorrectSegmentation')\n",
"app.layout = cs.layout\n",
"cs.callbacks(app)\n",
"show_app(app)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
20 changes: 20 additions & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: dash_canvas
channels:
- plotly
- conda-forge
- defaults
dependencies:
- python=3.6
- numpy
- pandas
- matplotlib
- nbserverproxy
- appmode
- scikit-learn
- scikit-image
- notebook
- dash==0.39.0 # The core dash backend
- plotly==3.7.1 # Plotly graphing library used in examples
- dash-daq==0.1.0 # DAQ components (newly open-sourced!)
- pip:
- dash-canvas
143 changes: 143 additions & 0 deletions binder/segmentation.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Segmentation App\n",
"Here we show a simple segmentation app using the [dash-canvas](https://github.com/plotly/dash-canvas) tool."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from IPython import display\n",
"import os\n",
"def show_app(app, port = 9999, \n",
" width = \"100%\", \n",
" height = \"900px\", \n",
" offline = False,\n",
" in_binder = None):\n",
" in_binder ='JUPYTERHUB_SERVICE_PREFIX' in os.environ if in_binder is None else in_binder\n",
" if in_binder:\n",
" base_prefix = '{}proxy/{}/'.format(os.environ['JUPYTERHUB_SERVICE_PREFIX'], port)\n",
" url = 'https://hub.mybinder.org{}'.format(base_prefix)\n",
" app.config.requests_pathname_prefix = base_prefix\n",
" else:\n",
" url = 'http://localhost:%d' % port\n",
" \n",
" iframe = '<a href=\"{url}\" target=\"_new\">Open in new window</a><hr><iframe src=\"{url}\" width={width} height={height}></iframe>'.format(url = url, \n",
" width = width, \n",
" height = height)\n",
" \n",
" display.display_html(iframe, raw = True)\n",
" if offline:\n",
" app.css.config.serve_locally = True\n",
" app.scripts.config.serve_locally = True\n",
" return app.run_server(debug=False, # needs to be false in Jupyter\n",
" host = '0.0.0.0',\n",
" port=port)\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import os, sys\n",
"sys.path.append('..')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import dash\n",
"import app1_seg as seg"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<a href=\"https://hub.mybinder.org/user/kmader-dash-canvas-ivyrnudq/proxy/9999/\" target=\"_new\">Open in new window</a><hr><iframe src=\"https://hub.mybinder.org/user/kmader-dash-canvas-ivyrnudq/proxy/9999/\" width=100% height=900px></iframe>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" * Serving Flask app \"Segmentation\" (lazy loading)\n",
" * Environment: production\n",
" WARNING: Do not use the development server in a production environment.\n",
" Use a production WSGI server instead.\n",
" * Debug mode: off\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
" * Running on http://0.0.0.0:9999/ (Press CTRL+C to quit)\n",
"127.0.0.1 - - [02/Apr/2019 16:52:36] \"GET / HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:52:37] \"GET /_dash-dependencies HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:52:39] \"GET /_dash-layout HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:52:39] \"POST /_dash-update-component HTTP/1.1\" 204 -\n",
"127.0.0.1 - - [02/Apr/2019 16:52:39] \"POST /_dash-update-component HTTP/1.1\" 204 -\n",
"127.0.0.1 - - [02/Apr/2019 16:52:39] \"POST /_dash-update-component HTTP/1.1\" 204 -\n",
"127.0.0.1 - - [02/Apr/2019 16:52:47] \"POST /_dash-update-component HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:52:59] \"POST /_dash-update-component HTTP/1.1\" 200 -\n",
"127.0.0.1 - - [02/Apr/2019 16:53:09] \"POST /_dash-update-component HTTP/1.1\" 200 -\n"
]
}
],
"source": [
"app = dash.Dash('Segmentation')\n",
"app.layout = seg.layout\n",
"seg.callbacks(app)\n",
"show_app(app)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}