How to convert image into dataframe

still accuracy is only 24%

In your updated code, what is the shape of arr right before this line of code?

df=pd.DataFrame(arr.reshape(-1, 3),columns=['r', 'g', 'b'])

Better if you could just share the updated code with me.

(430,430,3)
https://drive.google.com/file/d/1d5zoIkYHEQm24kA_V8aQ98J5OYOhN0lh/view?usp=sharing

i have omitted the index and now accuracy is 73%

Hey Stuti,

One improvement you can make is that opencv reads images in BGR order by default whereas in this problem, we need to submit RGB ordering. A simple fix is to change this order just after reading the image using this line of code:

img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)

i did it that before submitting …

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I am interested to share my thought to know what happening in the background, I hope you aware of it. I make 4x4x3 image in Photoshop and then reshape into (-1,3). The codes as follows

import cv2
import numpy as np
import pandas as pd
im = cv2.imread('template_3.jpg')
print(im.shape)
print(im)
a = im.reshape(-1,3)
df = pd.DataFrame(a,columns=['r','g','b'])
print(df)