Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
yolov3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GynEyn_ML
yolov3
Commits
aa290799
Commit
aa290799
authored
Feb 22, 2021
by
Kishore Bandi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
fbb85170
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
0 deletions
+133
-0
data-augmentation-by_keras.ipynb
...Tuning/Data_Augumentatin/data-augmentation-by_keras.ipynb
+133
-0
No files found.
Hyperparameters Tuning/Data_Augumentatin/data-augmentation-by_keras.ipynb
0 → 100644
View file @
aa290799
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# # example of zoom image augmentation\n",
"# from numpy import expand_dims\n",
"# from keras.preprocessing.image import load_img\n",
"# from keras.preprocessing.image import img_to_array\n",
"# from keras.preprocessing.image import ImageDataGenerator\n",
"# from matplotlib import pyplot"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# # load the image\n",
"# img = load_img('./1.png')\n",
"# # convert to numpy array\n",
"# data = img_to_array(img)\n",
"# # expand dimension to one sample\n",
"# samples = expand_dims(data, 0)\n",
"# # create image data augmentation generator\n",
"# datagen = ImageDataGenerator(zoom_range=[0.5,1.0])\n",
"# # prepare iterator\n",
"# it = datagen.flow(samples, batch_size=1)\n",
"# # generate samples and plot\n",
"# for i in range(9):\n",
"# \t# define subplot\n",
"# \tpyplot.subplot(330 + 1 + i)\n",
"# \t# generate batch of images\n",
"# \tbatch = it.next()\n",
"# \t# convert to unsigned integers for viewing\n",
"# \timage = batch[0].astype('uint8')\n",
"# \t# plot raw pixel data\n",
"# \tpyplot.imshow(image)\n",
"# # show the figure\n",
"# pyplot.show()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"from keras.preprocessing.image import ImageDataGenerator\n",
"\n",
"datagen = ImageDataGenerator(\n",
" rotation_range=40,\n",
" width_shift_range=0.2,\n",
" height_shift_range=0.2,\n",
" rescale=1./255,\n",
" shear_range=0.2,\n",
" zoom_range=0.2,\n",
" horizontal_flip=True,\n",
" fill_mode='nearest')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img\n",
"\n",
"datagen = ImageDataGenerator(\n",
" rotation_range=40,\n",
" width_shift_range=0.2,\n",
" height_shift_range=0.2,\n",
" shear_range=0.2,\n",
" zoom_range=0.2,\n",
" horizontal_flip=True,\n",
" fill_mode='nearest')\n",
"\n",
"img = load_img('./1.png') # this is a PIL image\n",
"x = img_to_array(img) # this is a Numpy array with shape (3, 150, 150)\n",
"x = x.reshape((1,) + x.shape) # this is a Numpy array with shape (1, 3, 150, 150)\n",
"\n",
"# the .flow() command below generates batches of randomly transformed images\n",
"# and saves the results to the `preview/` directory\n",
"i = 0\n",
"for batch in datagen.flow(x, batch_size=1,\n",
" save_to_dir='./', save_prefix='cervix', save_format='png'):\n",
" i += 1\n",
" if i > 20:\n",
" break # otherwise the generator would loop indefinitely"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"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.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment