"Plagiarism" is an academic concept, not a legal one
Plagiarising the work of another without attribution is academic misconduct in every reputable academic facility and can lead to disciplinary action. But it's not against the law, and you can't be sued for doing it.
Copyright violation is against the law
You violate copyright when you copy or make a derivative work from the copyrighted work of another without permission or without an exemption under the law.
In some jurisdictions, authors and artists have moral copyright, which operates alongside proprietary copyright and gives certain rights, including the right of attribution and the right for their work to be treated respectfully. In those jurisdictions, even if you have the copyright holder's permission, you must still respect the moral rights.
Let's make some things explicit by considering a particular artwork. Say, this one:
This particular piece is not subject to copyright because a) it was created before there was such a concept, and b) da Vinci died in 1519, so if there had been a copyright law, copyright in this work would have long expired. So, you can make as many copies of this as you like.
Now, let's consider what the situation would be if Leonardo's alchemical pursuits had been more successful and instead of dying in 1519, he died last Tuesday.
If you want to make a copy of this image, you must have Leonardo's heir(s) permission or be operating under an exemption under copyright law in your jurisdiction.
When you train your AI, you will need to make a copy of the image. Do you have permission? Do you have a relevant exemption?
If you obtained your images by scraping websites then the answers are no and (probably) no.
Whether the image has metadata identifying the author is irrelevant to answering the questions. Whether there is any way of identifying the artist is also irrelevant - you still need their permission even if you don't know who to ask.
If your AI, when prompted, generates an image that is strikingly similar to a copyrighted image it was trained on, that is a derivative work and you need permission for that. Under current law, the programer(s) are likely the copyright violators rather than the users of the AI.