Is it allowed to compare god with self. Can I consider myself as Lord Ram, Lord Krishna or is it a sin to compare myself with such gods?
It depends on the result of comparison.
You can, and should compare yourself with God.
What is the result of any comparison - better, worse, equal - right ?
So, what is the result of comparing myself with Bhagavan ? If I say 'I am worse. God is better' - it is not sin.
'Bhagavad-Guna, Sva-dosha, Prakatanam Kuru' - Loudly praise lord and denigrate yourself.
This is from Vaishnava Paramparai upanyasam by Velukkudi Krishnan swami :
When an acharya was giving upanyasam several hundred years back in srirangam, a layman in audience starting scolding the acharya in front of everyone. Once he was done, the acharya called the layman up to the stage and gave him his shawl/money and thanked him. When shishyas asked why, he replied 'Everyday I have 2 duties - Praise the qualities of Bhagavan. And Blame my own insufficiency. All these days, I only had time for the former, but neglected the latter. This man helped me in doing my duty, so I showed my gratitude to him'.