[This is sort of a duplicate of Detect piano notes and chords, from which I'm pasting my answer]
Huge advances have/are recently being made in regards to software that addresses tasks precisely like this one (and many others, such as image classification, "deep fake" video generation, natural language processing summarization, speech recognition, etc.), due principally to the arrival of new techniques I'm sure we've all (or mostly have) heard of -- that is, Deep Learning. By far the best software for this I am aware of yet is called "AnthemScore". It's pretty incredible what it can do.
https://www.lunaverus.com/
As I allude to, it's algorithms are based off of some of the latest techniques in machine learning (see site for more details & exact explanation). I paid $40 for it 4 years ago but they let me update to the latest versions and I honestly have used it so darn much, it was definitely worth the upfront cost. Anytime I suddenly am thinking of, remembering, or listening to a song and think "I wish I had the sheet music for this" I run it through AnthemScore and more or less I end up with the sheet music. It's certainly good enough that all I wanted to know about the music has been revealed. Of course don't expect a 100% perfectly edited score to just pop out. Yeah right, we're....probably 5-10 years away from that.........
For example, without posting the exact sheet music due to potential copyright issues, let me just say I ran the song "Abandon Window" by Jon Hopkins (youtube it) through this software and got the exact notes he plays on piano perfectly. In spite of all the additional electronics processing. I've ran The Sims I (the computer game) both build (which is actually piano music) and buy mode (which is not piano music, but orchestral) and likewise the outcomes are very, very close to what the exact scores would be. It isn't perfect, but it's a marvel of software power, that's for sure. I use it for any song, regardless of it has piano (e.g. even avant garde electronic deep house like Above and Beyond tracks) and I always get something useful which I can then adjust as needed in MuseScore, etc.
For example, here is a youtube video I just found (specifically listed under Creative Commons licensing [i.e. totally free for any use]) of Yuja Wang playing Rachmaninoff's famous 18th variation from his Op. 43 Variations:
and here is a link to the result (unedited) straight from AnthemScore (I downloaded the mp3 from the youtube video using the linux tool youtube-dl
), which I've posted in the pubic domain to my MuseScore account (according to the rights granted by the video being posted CC):
https://musescore.com/user/38320336/scores/7108932?share=copy_link
Is it perfect looking (editing-wise)? Of course not. Does it sound just about exactly like what the very best piano arrangement could sound like? Pretty much. I'd say 90% satisfactorily and in many ways, picks up on things and implements them in the notation in ways a human never would have thought of. This took less than 5 minutes including the downloading of the mp3 from youtube.


And yes, MIDI is, of course, one of the possible options for export from the program.
MIDI, xml, wav, or pdf, I believe are the filetype export options. I typically always go for xml and load that into MuseScore, and make some edits to improve it. (Again, in the example above, I have made none though to illustrate what the software can do completely itself -- the only thing I added was the piano dynamics mark (nonetheless all the notes come with specific velocity values directly inferred from the analysis of the input mp3 recording), and the pedal marks [I just ctrl-a selected everything and added one long pedal marking, simply out of haste]).
And here's what it looked like in AnthemScore (notice the detection of notes clearly being based off of visualizing the fundamental frequencies of the various harmonics present - ultimately this is actually visual machine learning, just like Google's famous image recognition deep learning methods)
