There is a simple way - don't set them.
20th century methods treated everyone as cogs in a machine. Then people were surprised when the machine ran as slow as the slowest cog. So they set out to micro-manage every cog. It didn't work then, and it doesn't work now.
For one simple reason - you can only estimate how long things take if you've done them before. Repeatedly. Oh, you can guess, from adding together bits of the task etc. But you always miss something. So does your contractor deserve punishment because you've estimated badly?
If your hardware or software is so standard that you can set deadlines accurately, go out and buy it off the shelf. Don't make it yourself, or hire somebody else to make it for you.
But if you are asking people to venture into the unknown and create something new, don't work with a goal - work with a system.
The system sketches out what you believe will be the timeline and everything which is required at every point - people, data, hardware, finance. If you are doing this with a contractor, make sure you're both on the same system and they aren't simply operating a magic box (no-one can see in side where the magic happens). And set a host of milestones along the way - smaller tasks you can schedule more accurately.
Once you see the overall timeline, you can dynamically allocate resource. Perhaps if we put more people on it, we could get this done quicker. Some parts, of course will be fixed because that person or resource is shared or allocated elsewhere. If, for example, you have an expert datascientist only available for one week, you must look at what can be made ready for their slot. You can set sprints - all hands on deck short period where a milestone is hit - just don't forget you can't sprint all the time.
Then animate this system. Make it dynamic, automatically reallocating resources and rescheduling as things get done, overshoot etc. See where you have a fixed point but things aren't going to be ready - and what you can reallocate to make it happen. Create a visual dashboard, so everyone can see what is happening and where they are in relation to it.
And expect over-runs. What you have created is a perfect world model. But you are working in uncharted territory. You have a butterfly wings effect - all it takes is one piece of code to take a day instead of an hour and everything goes off schedule increasingly. Create a back-up plan for overruns - more people, more resource - and a reward plan for under-runs (otherwise work expands to fill the time allotted).
One thing not to do is hold meetings, especially those with everybody in the room. The more meetings, the more time is lost. And meetings often act as a focus point for dissent, blame, loss of morale and short-term panic "solutions".