The function cv2.cvtColor(img, cv2.COLOR_RGB2HSV)
converts an RGB image to an HSV image.
When I save this image and open it using an image viewer, why is it visually different from an RGB image?
RGB
HSV
opencv assumes BGR images in imwrite and imshow and will handle any 3 channel mat as if it was BGR. So it handles the HSV matrix as BGR when we save or show an image. Now, regarding the viewer, our eyes are used to recognizing the pixels as RGB and hence interpret the H channel as Red and S as Green and V as Blue. Micka explained it beautifully in the comments.