Last I checked, the train from Ljubljana only goes to Koper, not Piran - you'd have to take a bus or catch a taxi on to Piran from there. You may also find the buses to/from Ljubljana are quicker and more frequent as well. You may find a direct bus to Piran from Ljubljana. Check the schedules here:
Even so, refugees are trying to get through Slovenia and Croatia on to other countries on international trains that cross borders. (Though I think Slovenia may take some refugees, Germany has pledged to take the most, so I think that's where most are headed.) The trains and buses that go between Ljubljana and Koper/Piran are national trains within Slovenia that don't cross borders. I would not expect to find many refugees on them.
That said, Piran is a lovely town.
You might also consider renting a car for the day to go to Piran, unless you can work out good bus/train schedules.