Marriage is either highly recommended or obligatory depending on the situation of the person. It is highly recommended for people in general to get married as the prophetic orders to Muslims: تناكحوا تناسلوا Get married, Have children. Hadeeth states: Marriage is from Sunnah, so any one who abandons my Sunnah is not from me. النكاح من سنتي فمن رغب عن سنتي فليس مني.
Marriage becomes obligatory when a person is in danger of falling in sinful acts just because of being unmarried.
In the case mentioned in the question we must emphasize that marriage should never cause injustice to your spouse if you do have any interest in other gender. You need to consult medical and psychological experts and get proper treatment then go for marriage. Some times, marriage itself can help in treatment.
You should never give up or surrender to abnormal situation which is away from the teachings of Allah (SWT).
Leaving marriage might worsen such cases, but with out proper treatment, you might do injustice on an innocent person whom you want to live with when you are still not adequate to be a proper spouse.