My assignment is - "given 2 images , you have to classify that is written by same person…
- User
My assignment is - "given 2 images , you have to classify that is written by same person or not if it is same person then output will be 1 else output will be 0".
For that problem I have one folder of dataset . In that folder(dataset) I have 1352 of subfolders, each subfolder define different person's handwritting. each folder have 4 or 5 or 6 handwritting of that person. so make a model from scratch , how to read folder and how to make the model . okay ? Is that problem is clear for you , if you have any question tell me?..... return imageuse the above code to preprocess of each image. After preprocessing, when you are going to pair images make sure that positive images (i.e. in that image text is written by same person) or negative images (i.e. in that image text is written by different person) width should be less than 600 or grater than 600. use get the size by img.shape[1]. Now your work is first make the pair as I mention below. okay?
I give you an example - " Suppose subfolder1 has images A0.jpg, A1.jpg, A2.jpg, A3.jpg . You preprocess the image and found the shape of the images like - (100x467), (98x784),(90x675), (105x562). Then you see than 2 image width is greter than 600 and 2 is less than 600. So you can a group of [A0.jpg,A3.jpg] and [A1.jpg, A2.jpg]. Suppose subfolder2 has images A0.jpg, A1.jpg, A2.jpg, A3.jpg . You preprocess the image and found the shape of the images like - (100x703), (98x899),(90x512), (105x900). Then you see than 3 image width is greter than 600 and 1 is less than 600. So you can a group of [A0.jpg, A1.jpg, A3.jpg] and [A2.jpg]. And when you pair the images you can make positive image (subfolder1/A0.jpg, subfolder1/A3.jpg), (subfolder1/A1.jpg, subfolder1/A2.jpg), (subfolder2/A0.jpg, subfolder2/A1.jpg), (subfolder2/A0.jpg, subfolder2/A3.jpg), (subfolder2/A1.jpg, subfolder2/A3.jpg). for negative image : whose width is less than 600 [ (subfolder1/A0.jpg, subfolder2/A0.jpg) or (subfolder1/A0.jpg, subfolder2/A1.jpg) or (subfolder1/A0.jpg, subfolder2/A3.jpg) {choose any one of them for subfolder1/A0.jpg because I need to balance positive and negative images }, (subfolder1/A3.jpg, subfolder2/A0.jpg) or (subfolder1/A3.jpg, subfolder2/A1.jpg) or (subfolder1/A3.jpg, subfolder2/A3.jpg){choose any one of them for subfolder1/A3.jpg }] and whose width is grater than 600 [(subfolder1/A1.jpg, subfolder2/A2.jpg){There is only one large image so choose that only}, (subfolder1/A2.jpg, subfolder2/A2.jpg)]. Now combine these two. "
As I say in the imstructuction - for each subfolder you can make 2 folder or list one for the large image whose size is grater than 600 and one for the small image whose size is less than 600. than pair the large image with large image and small image with small image. okay? When you select one image to pair an image, In that time you will immediately select another list(if image is small select small folder , if image is large then select large folder) to pair that image with first one for the negative image also.
- Assistant
Okay, I understand the problem and the instructions. So, I need to read the dataset folder and preprocess each image using the provided function. Then I need to group the images based on their size to generate pairs of images to classify if they are written by the same person or not. Finally, I will train a model using these pairs of images as input and the classification outputs as labels. Is that correct?
- User
- Assistant
Yes, I understand the problem and the instructions. To summarize, I need to develop a model to classify if two images are written by the same person or not using a dataset with 1352 subfolders that define different people's handwriting. Each folder has between 4 to 6 images of that person's handwriting. I need to preprocess each image using the provided function, group the images based on their size, and generate pairs of images to classify if they are written by the same person or not. To create the pairs, I will group the images into two lists, one for images whose size is less than 600 and one for images whose size is greater than 600. Then, I will pair the large images with large images and small images with small images. For negative pairs, I will select images from the other list (small for large and large for small) and make sure the pair has a width less than or greater than 600 accordingly. Finally, I will train a model using these pairs of images as input and the classification outputs as labels.
- User
provide code for that
- Assistant