Skip to content

Instantly share code, notes, and snippets.

@shaan-shah
Created September 14, 2020 17:23
Show Gist options
  • Save shaan-shah/30a1b405605c1d78e19584d27b51f6a7 to your computer and use it in GitHub Desktop.
Save shaan-shah/30a1b405605c1d78e19584d27b51f6a7 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%reload_ext autoreload\n",
"%autoreload 2\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from fastai.vision import *\n",
"from fastai.metrics import error_rate"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"bs = 64\n",
"# bs = 16 # uncomment this line if you run out of memory even after clicking Kernel->Restart"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [],
"source": [
"path=Path('data/Candle Sticks/CandleData')\n",
"path_save=Path('data/Candle Sticks/Processed')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[PosixPath('data/Candle Sticks/CandleData/Up'),\n",
" PosixPath('data/Candle Sticks/CandleData/Down'),\n",
" PosixPath('data/Candle Sticks/CandleData/models'),\n",
" PosixPath('data/Candle Sticks/CandleData/.ipynb_checkpoints')]"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"path.ls()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"np.random.seed(42)\n",
"data = ImageDataBunch.from_folder(path, train=\".\", valid_pct=0.2,\n",
" ds_tfms=get_transforms(flip_vert=False, max_lighting=0.1, max_zoom=1.05, max_warp=0.,max_rotate=3), size=224, num_workers=4).normalize(imagenet_stats)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Down', 'Up']"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data.classes"
]
}
],
"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.8.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment