smaranjitghose / ArtCV

Randomly Exploring Computer Vision techniques to create eye catching art out of plain boring images!
MIT License
49 stars 37 forks source link

added script for colorizing b&w images along with trained CNN model #66

Closed pravallika-1305 closed 3 years ago

pravallika-1305 commented 3 years ago

@smaranjitghose I added the script for conversion but I am not sure why the color isn't as expected when I run it on my machine locally, while manual testing on jupyter notebook... I got the expected results. I am looking into it, if you know of the reason then please suggest! I am sharing the link to my colab notebook here. https://colab.research.google.com/drive/1GHkONsIhZOqPof3M9LfQZeXC8pzKmK61?usp=sharing

smaranjitghose commented 3 years ago

@smaranjitghose I added the script for conversion but I am not sure why the color isn't as expected when I run it on my machine locally, while manual testing on jupyter notebook... I got the expected results. I am looking into it, if you know of the reason then please suggest! I am sharing the link to my colab notebook here. https://colab.research.google.com/drive/1GHkONsIhZOqPof3M9LfQZeXC8pzKmK61?usp=sharing

Fanatastic work @pravallika-1305

Please have a look at the suggestions above

smaranjitghose commented 3 years ago

@smaranjitghose I added the script for conversion but I am not sure why the color isn't as expected when I run it on my machine locally, while manual testing on jupyter notebook... I got the expected results. I am looking into it, if you know of the reason then please suggest! I am sharing the link to my colab notebook here. https://colab.research.google.com/drive/1GHkONsIhZOqPof3M9LfQZeXC8pzKmK61?usp=sharing

Well, for that we need to use some explainable ai methods like gradcam. Have a look at my deeppixel repository.

pravallika-1305 commented 3 years ago

Ok Sure! I will do the suggested changes..and get back in two days?

smaranjitghose commented 3 years ago

Ok Sure! I will do the suggested changes..and get back in two days?

Sure

smaranjitghose commented 3 years ago

Ok Sure! I will do the suggested changes..and get back in two days?

Any updates @pravallika-1305 ?

pravallika-1305 commented 3 years ago

hey! I need more time, I am a beginner at this & I am still learning about gradcam... So, apart from that, I will push the suggested changes in a day or 2.

smaranjitghose commented 3 years ago

hey! I need more time, I am a beginner at this & I am still learning about gradcam... So, apart from that, I will push the suggested changes in a day or 2.

gradcam? Did I assign you that?😅 I don't exactly remember. Don't worry @pravallika-1305. You are doing great and much ahead of just a "beginner".

I meant did you incorporate the changes I suggested above. Take a couple of days more

pravallika-1305 commented 3 years ago

Hey! I changed everything except the function for conversion of image colorspace, I am not able to figure out how exactly to implement the suggested function in a way that it matches my model.

smaranjitghose commented 3 years ago

Hey! I changed everything except the function for conversion of image colorspace, I am not able to figure out how exactly to implement the suggested function in a way that it matches my model.

What do you want to convert? Can you please elaborate?

As in once I read an image, get the pixel values in a numpy array.. Then?

pravallika-1305 commented 3 years ago

make the numpy array a float array, normalize it so that I can use rgb2lab for converting it into LAB colorspace then extract the L values, reshape it. Now, predict the A,B values and combine the arrays...into a single LAB array. Finally, convert it into RGB again.

smaranjitghose commented 3 years ago

make the numpy array a float array, normalize it so that I can use rgb2lab for converting it into LAB colorspace then extract the L values, reshape it. Now, predict the A,B values and combine the arrays...into a single LAB array. Finally, convert it into RGB again.

For converting it to and from LAB Space,

Simply use

img = cv2.imread("path")
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
l, a, b = cv2.split(img)
l = # whatever reshaping,etc you wish to do

img_2 = cv2.merge(l,a,b)
img = cv2.cvtColor(img, cv2.COLOR_LAB2RGB)
pravallika-1305 commented 3 years ago

Hey, I tried something similar the other day but since my model takes a list of images as input there were some depth errors which I wasn't able to sort.

smaranjitghose commented 3 years ago

Hey, I tried something similar the other day but since my model takes a list of images as input there were some depth errors which I wasn't able to sort.

Depth Error? I have to look the code to solve it then😅