Commit e282e876 authored by giwi97's avatar giwi97

dataset import

parent 661b93e8
......@@ -53,6 +53,135 @@
" return np.array(features).flatten()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"E:\\Users\\Acer\\anaconda3\\lib\\site-packages\\numpy\\core\\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
" return array(a, dtype, copy=False, order=order)\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Fruit</th>\n",
" <th>Number</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Apple</td>\n",
" <td>3098</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Banana</td>\n",
" <td>2826</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Lemon</td>\n",
" <td>3747</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Lime</td>\n",
" <td>2514</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Orange</td>\n",
" <td>2834</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Pear</td>\n",
" <td>2082</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Peach</td>\n",
" <td>2026</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Fruit Number\n",
"0 Apple 3098\n",
"1 Banana 2826\n",
"2 Lemon 3747\n",
"3 Lime 2514\n",
"4 Orange 2834\n",
"5 Pear 2082\n",
"6 Peach 2026"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def loadimage(arr,n,name_of_fruit):\n",
" label=[]\n",
" for i in range(n):\n",
" strr = \"rgb/\"+name_of_fruit+\"_\"+str(i+1)+\"/*.png\"\n",
" #print(strr)\n",
" for file in glob.glob(strr):\n",
" img=np.asarray(plt.imread(file))\n",
" arr.append(img)\n",
" label.append(name_of_fruit)\n",
" return arr,label\n",
"\n",
"apple=[]\n",
"banana =[]\n",
"lemon=[]\n",
"lime=[]\n",
"orange=[]\n",
"peach=[]\n",
"pear=[]\n",
"\n",
"apple,label_apple=loadimage(apple,5,\"apple\")\n",
"banana,label_banana=loadimage(banana,4,\"banana\")\n",
"lemon,label_lemon=loadimage(lemon,6,\"lemon\")\n",
"lime,label_lime=loadimage(lime,4,\"lime\")\n",
"orange,label_orange=loadimage(orange,4,\"orange\")\n",
"peach,label_peach=loadimage(peach,3,\"peach\")\n",
"pear,label_pear=loadimage(pear,3,\"pear\")\n",
"\n",
"raw_atribut = {'Fruit': ['Apple','Banana','Lemon','Lime','Orange', 'Pear', 'Peach'],\n",
" 'Number': [np.shape(apple)[0],np.shape(banana)[0],np.shape(lemon)[0],np.shape(lime)[0],np.shape(orange)[0],np.shape(peach)[0],np.shape(pear)[0]]}\n",
"atribut= pd.DataFrame(raw_atribut,\n",
" columns=['Fruit','Number'])\n",
"atribut"
]
},
{
"cell_type": "code",
"execution_count": null,
......
......@@ -53,6 +53,135 @@
" return np.array(features).flatten()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"E:\\Users\\Acer\\anaconda3\\lib\\site-packages\\numpy\\core\\_asarray.py:83: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray\n",
" return array(a, dtype, copy=False, order=order)\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Fruit</th>\n",
" <th>Number</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Apple</td>\n",
" <td>3098</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Banana</td>\n",
" <td>2826</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Lemon</td>\n",
" <td>3747</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Lime</td>\n",
" <td>2514</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Orange</td>\n",
" <td>2834</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Pear</td>\n",
" <td>2082</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Peach</td>\n",
" <td>2026</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Fruit Number\n",
"0 Apple 3098\n",
"1 Banana 2826\n",
"2 Lemon 3747\n",
"3 Lime 2514\n",
"4 Orange 2834\n",
"5 Pear 2082\n",
"6 Peach 2026"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def loadimage(arr,n,name_of_fruit):\n",
" label=[]\n",
" for i in range(n):\n",
" strr = \"rgb/\"+name_of_fruit+\"_\"+str(i+1)+\"/*.png\"\n",
" #print(strr)\n",
" for file in glob.glob(strr):\n",
" img=np.asarray(plt.imread(file))\n",
" arr.append(img)\n",
" label.append(name_of_fruit)\n",
" return arr,label\n",
"\n",
"apple=[]\n",
"banana =[]\n",
"lemon=[]\n",
"lime=[]\n",
"orange=[]\n",
"peach=[]\n",
"pear=[]\n",
"\n",
"apple,label_apple=loadimage(apple,5,\"apple\")\n",
"banana,label_banana=loadimage(banana,4,\"banana\")\n",
"lemon,label_lemon=loadimage(lemon,6,\"lemon\")\n",
"lime,label_lime=loadimage(lime,4,\"lime\")\n",
"orange,label_orange=loadimage(orange,4,\"orange\")\n",
"peach,label_peach=loadimage(peach,3,\"peach\")\n",
"pear,label_pear=loadimage(pear,3,\"pear\")\n",
"\n",
"raw_atribut = {'Fruit': ['Apple','Banana','Lemon','Lime','Orange', 'Pear', 'Peach'],\n",
" 'Number': [np.shape(apple)[0],np.shape(banana)[0],np.shape(lemon)[0],np.shape(lime)[0],np.shape(orange)[0],np.shape(peach)[0],np.shape(pear)[0]]}\n",
"atribut= pd.DataFrame(raw_atribut,\n",
" columns=['Fruit','Number'])\n",
"atribut"
]
},
{
"cell_type": "code",
"execution_count": null,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment