That code doesn't look quite right if you want to check each image. The first line should be within the foreach loop so it gets reset each time through.
It may be difficult to tell if the images are truly unique but you may be able to compare image URLs.
If you want to compare with the previous entry in the loop then store each one and compare (untested):
Code:
{assign var=oldImg value=""}
{foreach from=$variants item=v key=vid}
{if $v.is_image ne "" and $v.image_url ne $oldImg}
...
{assign var=oldImg value=$v.image_url}
{/if}
{/foreach}
But if you truly want to ensure they are all unique this should be done in the php file.