I was in the same situation as you last year (F1---H1B). I called IRS and they answered:
It depends on what form you use for tax return. If you use 1040, which is for resident, you can not claim tax treaty. If you use 1040NR, yes, you can claim it.