├── zip-unzip ├── readme.md ├── zip.ipynb └── unzip.ipynb ├── README.md └── kullanima-hazir-veriseti-olustur ├── dosyalar └── akis.jpg ├── readme.md ├── veriseti_oku.ipynb └── veriseti_olustur.ipynb /zip-unzip/readme.md: -------------------------------------------------------------------------------- 1 | Bu klasörde çeşitli sıkıştırma araçları yer almaktadır. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Bu repoda derin öğrenme uygulamalarını geliştirirken ihtiyacınız olabilecek ufak kullanışlı araçlar yer almaktadır. 2 | -------------------------------------------------------------------------------- /kullanima-hazir-veriseti-olustur/dosyalar/akis.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deeplearningturkiye/derin-ogrenme-alet-cantasi/HEAD/kullanima-hazir-veriseti-olustur/dosyalar/akis.jpg -------------------------------------------------------------------------------- /kullanima-hazir-veriseti-olustur/readme.md: -------------------------------------------------------------------------------- 1 | ## BU ARAÇ NE İŞE YARIYOR? 2 | 3 | - Bu araç ile **resimler** isminde klasörde bulunan resimleri **x_train, x_test, y_train ve y_test** adında toplam 4 dosyaya kaydedebilirsiniz. 4 | - Test ve eğitim verilerinin oranlarını (varsayılan: test %20 eğitim %80) belirleyebilirsiniz. 5 | 6 | ![alt text](https://raw.githubusercontent.com/deeplearningturkiye/derin-ogrenme-alet-cantasi/master/kullanima-hazir-veriseti-olustur/dosyalar/akis.jpg) 7 | 8 | ## NASIL KULLANILIR? 9 | - Öncelikle **resimler** isminde bir klasör oluşturun. Bu klasörde her bir sınıf için bir klasör oluşturun. 10 | - Her bir sınıfa ait klasöre o sınıfa ait resimleri atın. 11 | -------------------------------------------------------------------------------- /zip-unzip/zip.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "!tar cvfz hepsibununicinde.tar.gz *" 12 | ] 13 | } 14 | ], 15 | "metadata": { 16 | "kernelspec": { 17 | "display_name": "Python 3", 18 | "language": "python", 19 | "name": "python3" 20 | }, 21 | "language_info": { 22 | "codemirror_mode": { 23 | "name": "ipython", 24 | "version": 3 25 | }, 26 | "file_extension": ".py", 27 | "mimetype": "text/x-python", 28 | "name": "python", 29 | "nbconvert_exporter": "python", 30 | "pygments_lexer": "ipython3", 31 | "version": "3.6.2" 32 | } 33 | }, 34 | "nbformat": 4, 35 | "nbformat_minor": 2 36 | } 37 | -------------------------------------------------------------------------------- /zip-unzip/unzip.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "# bu araç ile zip'li dosyayı unzip yapabilirsiniz\n", 12 | "\n", 13 | "import zipfile\n", 14 | "\n", 15 | "dosya_adi = \"veriseti.zip\"\n", 16 | "cikarilacak_klasor = \"\" # aynı klasöre çıkartmak için boş bırakabilirsiniz\n", 17 | "\n", 18 | "with zipfile.ZipFile(dosya_adi,\"r\") as zip_ref:\n", 19 | " zip_ref.extractall(cikarilacak_klasor)" 20 | ] 21 | } 22 | ], 23 | "metadata": { 24 | "kernelspec": { 25 | "display_name": "Python 3", 26 | "language": "python", 27 | "name": "python3" 28 | }, 29 | "language_info": { 30 | "codemirror_mode": { 31 | "name": "ipython", 32 | "version": 3 33 | }, 34 | "file_extension": ".py", 35 | "mimetype": "text/x-python", 36 | "name": "python", 37 | "nbconvert_exporter": "python", 38 | "pygments_lexer": "ipython3", 39 | "version": "3.5.4" 40 | } 41 | }, 42 | "nbformat": 4, 43 | "nbformat_minor": 2 44 | } 45 | -------------------------------------------------------------------------------- /kullanima-hazir-veriseti-olustur/veriseti_oku.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "import numpy as np" 12 | ] 13 | }, 14 | { 15 | "cell_type": "code", 16 | "execution_count": 2, 17 | "metadata": { 18 | "collapsed": true 19 | }, 20 | "outputs": [], 21 | "source": [ 22 | "veriseti_klasoru = 'veriseti'" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 3, 28 | "metadata": { 29 | "collapsed": true 30 | }, 31 | "outputs": [], 32 | "source": [ 33 | "x_train = np.load(veriseti_klasoru+'/x_train.npy')\n", 34 | "x_test = np.load(veriseti_klasoru+'/x_test.npy')\n", 35 | "y_train = np.load(veriseti_klasoru+'/y_train.npy')\n", 36 | "y_test = np.load(veriseti_klasoru+'/y_test.npy')" 37 | ] 38 | } 39 | ], 40 | "metadata": { 41 | "kernelspec": { 42 | "display_name": "Python 3", 43 | "language": "python", 44 | "name": "python3" 45 | }, 46 | "language_info": { 47 | "codemirror_mode": { 48 | "name": "ipython", 49 | "version": 3 50 | }, 51 | "file_extension": ".py", 52 | "mimetype": "text/x-python", 53 | "name": "python", 54 | "nbconvert_exporter": "python", 55 | "pygments_lexer": "ipython3", 56 | "version": "3.6.2" 57 | } 58 | }, 59 | "nbformat": 4, 60 | "nbformat_minor": 2 61 | } 62 | -------------------------------------------------------------------------------- /kullanima-hazir-veriseti-olustur/veriseti_olustur.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "# Arda Mavi (https://github.com/ardamavi) tarafından Deep Learning Türkiye topluluğu için hazırlanmıştır.\n", 12 | "\n", 13 | "import os\n", 14 | "import numpy as np\n", 15 | "from os import listdir\n", 16 | "from scipy.misc import imread, imresize\n", 17 | "from keras.utils import to_categorical\n", 18 | "from sklearn.model_selection import train_test_split" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": null, 24 | "metadata": { 25 | "collapsed": true 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "resim_boyutu = 100\n", 30 | "kanal_sayisi = 1 # 1: Grayscale, 3: RGB\n", 31 | "etiket_sayisi = 10 # sınıf sayısı\n", 32 | "test_verisi_orani = 0.2 # %20 test\n", 33 | "resimler_klasoru = 'resimler'\n", 34 | "veriseti_klasoru = 'veriseti'" 35 | ] 36 | }, 37 | { 38 | "cell_type": "code", 39 | "execution_count": null, 40 | "metadata": { 41 | "collapsed": true 42 | }, 43 | "outputs": [], 44 | "source": [ 45 | "def resmi_al(resimler_klasoru):\n", 46 | " resim = imread(resimler_klasoru, flatten= True if kanal_sayisi == 1 else False)\n", 47 | " resim = imresize(resim, (resim_boyutu, resim_boyutu, kanal_sayisi))\n", 48 | " return resim" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": null, 54 | "metadata": { 55 | "collapsed": true 56 | }, 57 | "outputs": [], 58 | "source": [ 59 | "etiketler = listdir(resimler_klasoru) \n", 60 | "X, Y = [], []" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": null, 66 | "metadata": { 67 | "collapsed": true, 68 | "scrolled": true 69 | }, 70 | "outputs": [], 71 | "source": [ 72 | "for i, etiket in enumerate(etiketler):\n", 73 | " etiket_klasoru = resimler_klasoru+'/'+etiket\n", 74 | " \n", 75 | " for resim_adi in listdir(etiket_klasoru):\n", 76 | " resim = resmi_al(etiket_klasoru+'/'+resim_adi)\n", 77 | " X.append(resim)\n", 78 | " Y.append(i)" 79 | ] 80 | }, 81 | { 82 | "cell_type": "code", 83 | "execution_count": null, 84 | "metadata": { 85 | "collapsed": true 86 | }, 87 | "outputs": [], 88 | "source": [ 89 | "X = np.array(X).astype('float32')/255.\n", 90 | "X = X.reshape(X.shape[0], resim_boyutu, resim_boyutu, kanal_sayisi)\n", 91 | "Y = np.array(Y).astype('float32')\n", 92 | "Y = to_categorical(Y, etiket_sayisi)" 93 | ] 94 | }, 95 | { 96 | "cell_type": "code", 97 | "execution_count": null, 98 | "metadata": { 99 | "collapsed": true 100 | }, 101 | "outputs": [], 102 | "source": [ 103 | "if not os.path.exists(veriseti_klasoru+'/'):\n", 104 | " os.makedirs(veriseti_klasoru+'/')\n", 105 | "\n", 106 | "x_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=test_verisi_orani, random_state=42)" 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": null, 112 | "metadata": { 113 | "collapsed": true 114 | }, 115 | "outputs": [], 116 | "source": [ 117 | "np.save(veriseti_klasoru+'/x_train.npy', x_train)\n", 118 | "np.save(veriseti_klasoru+'/x_test.npy', x_test)\n", 119 | "np.save(veriseti_klasoru+'/y_train.npy', y_train)\n", 120 | "np.save(veriseti_klasoru+'/y_test.npy', y_test)" 121 | ] 122 | } 123 | ], 124 | "metadata": { 125 | "kernelspec": { 126 | "display_name": "Python 3", 127 | "language": "python", 128 | "name": "python3" 129 | }, 130 | "language_info": { 131 | "codemirror_mode": { 132 | "name": "ipython", 133 | "version": 3 134 | }, 135 | "file_extension": ".py", 136 | "mimetype": "text/x-python", 137 | "name": "python", 138 | "nbconvert_exporter": "python", 139 | "pygments_lexer": "ipython3", 140 | "version": "3.6.0" 141 | } 142 | }, 143 | "nbformat": 4, 144 | "nbformat_minor": 2 145 | } 146 | --------------------------------------------------------------------------------