text_plain_output_1.png
import cv2

import cv2

import matplotlib.pyplot as plt

import matplotlib.pyplot as plt

import numpy as np

import numpy as np

import numpy as np # linear algebra

import os

import os

import pandas as pd

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

path = '/kaggle/input/fruit-images-for-object-detection/train_zip/train'
fileslst = os.listdir(path)
imgs = []
for fle in fileslst:
    if fle.endswith('.jpg'):
        imgs.append(fle)
img = cv2.imread('/kaggle/input/fruit-images-for-object-detection/train_zip/train/' + imgs[1])
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
imgedg = []
imgedg0 = cv2.Canny(img[:, :, 0], 120, 200)
imgedg1 = cv2.Canny(img[:, :, 1], 120, 200)
imgedg2 = cv2.Canny(img[:, :, 2], 120, 200)

import numpy as np
import pandas as pd
import os

path = '/kaggle/input/fruit-images-for-object-detection/train_zip/train'
fileslst = os.listdir(path)
imgs = []
for fle in fileslst:
    if fle.endswith('.jpg'):
        imgs.append(fle)
imgar = []
y = pd.DataFrame(columns=['apl', 'ban', 'orn', 'mix'])
print(fileslst[:20])
for i in range(len(imgs)):
    img = cv2.imread('/kaggle/input/fruit-images-for-object-detection/train_zip/train/' + imgs[i])
    img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    img = cv2.resize(img, (28, 28))
    imgar.append(np.array(img))
    if imgs[i][0] == 'a':
        y.loc[i, 'apl'] = 1
    elif imgs[i][0] == 'b':
        y.loc[i, 'ban'] = 1
    elif imgs[i][0] == 'o':
        y.loc[i, 'orn'] = 1
    else:
        y.loc[i, 'mix'] = 1
imgarr = np.array([imgar])
imgarr = np.reshape(imgarr, (240, 1, 28, 28, 3))
print(np.shape(imgarr))
y = y.replace(np.nan, 0)
y = np.array([y])
y = np.reshape(y, (240, 4))
print(y[0])
plt.imshow(img)
img = cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
plt.subplot(231)
plt.imshow(img[:, :, 0])
plt.subplot(232)
plt.imshow(img[:, :, 1])
plt.subplot(233)
plt.imshow(img[:, :, 2])
imgedg = []
imgedg0 = cv2.Canny(img[:, :, 0], 120, 200)
imgedg1 = cv2.Canny(img[:, :, 1], 120, 200)
imgedg2 = cv2.Canny(img[:, :, 2], 120, 200)
plt.subplot(234)
plt.imshow(imgedg0)
plt.subplot(235)
plt.imshow(imgedg1)
plt.subplot(236)
plt.imshow(imgedg2)