Skip to content

Commit cfd8297

Browse files
authored
Merge pull request plotly#189 from plotly/dash-image-processing
Dash image processing
2 parents 2220a81 + cd6cd50 commit cfd8297

12 files changed

Lines changed: 1631 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn --pythonpath apps/dash-image-processing app:server
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Dash Image Processing App
2+
3+
4+
This is a demo of the Dash interactive Python framework developed by [Plotly](https://plot.ly/).
5+
6+
Dash abstracts away all of the technologies and protocols required to build an interactive web-based application and is a simple and effective way to bind a user interface around your Python code. To learn more check out our [documentation](https://plot.ly/dash).
7+
8+
Try out the [demo app here](https://dash-playground.plotly.host/dash-iamge-processing/).
9+
10+
![screenshot](images/screenshot.png "Screenshot")
11+
12+
13+
## Getting Started
14+
### Using the demo
15+
This demo lets you interactively explore different image processing
16+
filters. You can upload your own image or use the one provided with the
17+
demo.
18+
19+
Filters can be applied either to the whole image, or to selections
20+
created with one of the selection tools.
21+
22+
### Running the app locally
23+
24+
First create a virtual environment with conda or venv inside a temp folder, then activate it.
25+
26+
```
27+
virtualenv dash-image-processing-venv
28+
29+
# Windows
30+
dash-image-processing-venv\Scripts\activate
31+
# Or Linux
32+
source venv/bin/activate
33+
```
34+
35+
Clone the git repo, then install the requirements with pip
36+
```
37+
git clone https://github.com/plotly/dash-sample-apps
38+
cd dash-sample-apps/apps/dash-image-processing
39+
pip install -r requirements.txt
40+
```
41+
42+
Run the app
43+
```
44+
python app.py
45+
```
46+
47+
48+
## Development
49+
50+
### S3 Storage
51+
52+
This app uses S3 to store user input images. To use this app locally, make sure to create a `.env` file in the root directory with the following content:
53+
```
54+
BUCKETEER_AWS_SECRET_ACCESS_KEY=***********
55+
BUCKETEER_AWS_ACCESS_KEY_ID=***********
56+
BUCKETEER_BUCKET_NAME=**********
57+
```
58+
59+
All this information is given when you create a bucket in AWS. For Plotly devs, the bucket name is `dash-image-processing-bucket`.
60+
61+
### Dash Deployment Server
62+
If you are looking to host this app on the Dash Deployment Server, make sure:
63+
* That you have linked a Redis database to your app.
64+
* To configure S3 storage by adding the content of `.env` as environment variables (in Settings).
65+
66+
## About the app
67+
This app wraps Pillow, a powerful image processing library in Python, and abstracts all the operations through an easy-to-use GUI. All the computation is done on the back-end through Dash, and image transfer is optimized through session-based Redis caching and S3 storage.
68+
69+
### Motivation
70+
Recently, while we were experimenting with ImageJ, an image processing app in Java, we wondered if it was possible to bring two changes: port the app into a browser interface, and shift the computation to the backend (so that extremely large images can also be processed).
71+
72+
This is how we thought about making a Dash app that would wrap Pillow, the modern version of the Python Imaging Library. This was the natural thing to do because Dash itself is already based on Flask, and Plotly already has the graph objects for manipulating images. Adding S3 storage to keep the uploaded file and caching the operations with Redis were absolutely painless because of the easy integration with Python.
73+
74+
## Built With
75+
* [Dash](https://dash.plot.ly/) - Main server and interactive components
76+
* [Plotly Python](https://plot.ly/python/) - Used to create the interactive plots
77+
* [Pillow](http://scikit-learn.org/stable/documentation.html) - Apply operations to images
78+
* [Boto S3](http://boto.cloudhackers.com/en/latest/ref/s3.html) - Store User inputted images
79+
* [Redis](https://redis.io/documentation) - Cache the user input

0 commit comments

Comments
 (0)