diff --git a/01_UI_Fastai.ipynb b/01_UI_Fastai.ipynb index d0a9538..a0e85bb 100644 --- a/01_UI_Fastai.ipynb +++ b/01_UI_Fastai.ipynb @@ -2,8 +2,13 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, - "metadata": {}, + "execution_count": 2, + "metadata": { + "ExecuteTime": { + "end_time": "2019-05-25T13:29:35.349486Z", + "start_time": "2019-05-25T13:29:35.330833Z" + } + }, "outputs": [], "source": [ "from __future__ import print_function\n", @@ -26,22 +31,61 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": {}, + "execution_count": 3, + "metadata": { + "ExecuteTime": { + "end_time": "2019-05-25T13:29:36.358160Z", + "start_time": "2019-05-25T13:29:36.292632Z" + } + }, "outputs": [], "source": [ - "path = Path('./data/airplanes')" + "%reload_ext autoreload\n", + "%autoreload 2\n", + "%matplotlib inline\n", + "from IPython.core.interactiveshell import InteractiveShell\n", + "InteractiveShell.ast_node_interactivity = \"all\"" ] }, { "cell_type": "code", - "execution_count": 3, - "metadata": {}, + "execution_count": 4, + "metadata": { + "ExecuteTime": { + "end_time": "2019-05-25T13:29:38.399276Z", + "start_time": "2019-05-25T13:29:38.336388Z" + } + }, + "outputs": [ + { + "data": { + "text/plain": [ + "PosixPath('/Users/Natsume/.fastai/data/mnist_tiny')" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "path = untar_data(URLs.MNIST_TINY);path" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "ExecuteTime": { + "end_time": "2019-05-25T13:29:42.306001Z", + "start_time": "2019-05-25T13:29:41.732686Z" + } + }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "5d5041f2f6604ecfab32a6252b5eb4bb", + "model_id": "f0a7cdf1fd8b423e9a5590370db857a8", "version_major": 2, "version_minor": 0 }, @@ -57,13 +101,6 @@ "display_ui(path)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, @@ -88,7 +125,36 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.7.3" + }, + "varInspector": { + "cols": { + "lenName": 16, + "lenType": 16, + "lenVar": 40 + }, + "kernels_config": { + "python": { + "delete_cmd_postfix": "", + "delete_cmd_prefix": "del ", + "library": "var_list.py", + "varRefreshCmd": "print(var_dic_list())" + }, + "r": { + "delete_cmd_postfix": ") ", + "delete_cmd_prefix": "rm(", + "library": "var_list.r", + "varRefreshCmd": "cat(var_dic_list()) " + } + }, + "types_to_exclude": [ + "module", + "function", + "builtin_function_or_method", + "instance", + "_Feature" + ], + "window_display": false } }, "nbformat": 4, diff --git a/README.md b/README.md index 0ac343d..53a9621 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ psutil (process and system utilities) is a cross-platform library for retrieving git clone this repository -`gitclone https://github.com/asvcode/Vision_UI.git` +`git clone https://github.com/asvcode/Vision_UI.git` run `01_UI_Fastai.ipynb` ,specify your path and run `display_ui(path)` @@ -99,7 +99,7 @@ Colab does not currently support ipywidgets because their output is in its own f ### Future Work -- Currently on works with images using the `ImageDataBunch.from_folder` option. Plans to expand to `.from_csv` and `.from_df` +- Currently it works with images using the `ImageDataBunch.from_folder` option. Plans to expand to `.from_csv` and `.from_df` [![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE) diff --git a/vision_ui.py b/vision_ui.py index 79f4fdd..4eba7c5 100644 --- a/vision_ui.py +++ b/vision_ui.py @@ -12,8 +12,6 @@ import warnings warnings.filterwarnings('ignore') -image_path = './data/ReSize/test/000937384/20180420_204537.jpg' - def dashboard_one(): style = {'description_width': 'initial'} @@ -71,7 +69,7 @@ def dashboard_one(): display(dashboard_one.datain, dashboard_one.norma, dashboard_one.archi, xres_text, dashboard_one.pretrain_check, dashboard_one.f, dashboard_one.m) -def dashboard_two(): +def dashboard_two(path): button = widgets.Button(description="View") print('Augmentations') @@ -112,11 +110,13 @@ def dashboard_two(): def on_button_clicked(b): print('displaying augmetations') - display_augs() + display_augs(path) button.on_click(on_button_clicked) -def display_augs(): + +def display_augs(path): + image_path = ImageList.from_folder(path).items[0] def get_ex(): return open_image(image_path) out_flip = dashboard_two.doflip.value #do flip @@ -477,8 +477,9 @@ def on_button_clicked_info(b): with out: clear_output() print(f'Fastai Version: {fastai.__version__}') - print(f'Cuda: {torch.cuda.is_available()}') - print(f'GPU: {torch.cuda.get_device_name(0)}') + if torch.cuda.is_available(): + print(f'Cuda: {torch.cuda.is_available()}') + print(f'GPU: {torch.cuda.get_device_name(0)}') print(f'Python version: {sys.version}') print(psutil.cpu_percent()) print(psutil.virtual_memory()) # physical memory usage @@ -490,7 +491,7 @@ def on_button_clicked_info2(b): with out: clear_output() il = ImageList.from_folder(path) - print(f'No of items in folder: {len(il.items)}') + print(il) button_two.on_click(on_button_clicked_info2) @@ -646,7 +647,7 @@ def display_ui(path): dashboard_one() with out2: #augmentation - dashboard_two() + dashboard_two(path) with out3: #Batch print('Click to view Batch')