Skip to content

Commit

Permalink
fixed docemnts after review #1
Browse files Browse the repository at this point in the history
  • Loading branch information
omer-dor committed Feb 25, 2022
1 parent a90ddd4 commit 866cd73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
6 changes: 1 addition & 5 deletions fastai/vision/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
def __getitem__(self:Box, i): return self.children[i]

# Cell
def widget(
im, # An object IPython can display to be converted into a widget
*args,
**layout
) -> Output: # A context manager to display output as a widget
def widget(im,*args,**layout)-> Output:
"Convert anything that can be `display`ed by `IPython` into a widget"
o = Output(layout=merge(*args, layout))
with o: display(im)
Expand Down
14 changes: 5 additions & 9 deletions nbs/09c_vision.widgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@
"outputs": [],
"source": [
"#export\n",
"def widget(\n",
" im, # An object IPython can display to be converted into a widget\n",
" *args, \n",
" **layout \n",
") -> Output: # A context manager to display output as a widget\n",
"def widget(im,*args,**layout)-> Output:\n",
" \"Convert anything that can be `display`ed by `IPython` into a widget\"\n",
" o = Output(layout=merge(*args, layout))\n",
" with o: display(im)\n",
Expand Down Expand Up @@ -140,7 +136,7 @@
"source": [
"#export\n",
"def carousel(\n",
" children:(list,tuple)=(), # `Box` objects to display in a carousel\n",
" children:tuple=(), # `Box` objects to display in a carousel\n",
" **layout\n",
") -> Box: # An `ipywidget`'s carousel\n",
" \"A horizontally scrolling carousel\"\n",
Expand Down Expand Up @@ -291,8 +287,8 @@
"source": [
"#export\n",
"def _get_iw_info(\n",
" learn, # CNN `Learner`\n",
" ds_idx:int=0 # 0 for `train`, 1 for `valid`\n",
" learn,\n",
" ds_idx:int=0 # Index in `learn.dls`\n",
")->list:\n",
" \"For every image in `dls` `zip` it's `Path`, target and loss\"\n",
" dl = learn.dls[ds_idx].new(shuffle=False, drop_last=False)\n",
Expand Down Expand Up @@ -324,7 +320,7 @@
"\n",
" def _ipython_display_(self): display(self.widget)\n",
" def on_change_ds(self,change=None):\n",
" \"Toggle between training set view and validation set view\"\n",
" \"Toggle between training validation set view\"\n",
" info = L(o for o in self.iwis[self.dd_ds.index] if o[1]==self.dd_cats.value)\n",
" self.iw.set_fns(info.sorted(2, reverse=True).itemgot(0))"
]
Expand Down

0 comments on commit 866cd73

Please sign in to comment.