pull down to refresh

need this script optimized, it's for automatically cropping images in a specific way. basically it crops a central object (an old coin, a stamp, a trading card, etc), then applies a subtle background blur.
it's currently really quite slow. need to get it down to like a second or two at most.
or maybe some tips on how to write prompts to improve this script? kinda long, at 250 lines. AI's have been breaking it when i try. they can't grasp the whole thing.
pics are pretty large. 6000x4000 px
⬇️⬇️⬇️⬇️⬇️⬇️
I know this doesn't answer your bounty question but I thought it was good to touch on this.
The reason why AIs have problems is because they apply windowing to images for them to fit into their small resolutions (think 512x512). Perhaps there's a way to resize the images before analysis, make the AI define a mask and then recalculate that mask to the original dimensions and apply it.
reply
appreciate the input. i didn't know this and tbh i'm still largely an artisan programmer. e.g. not using AIs all the much. i just fed it a script i wrote and asked it to speed it up, removed duplicate processes etc. it gave some good suggestions but it broke the script pretty badly too
reply
Oh! I thought you were having the AI resize, but you had the AI code?
Just put the before ai and after ai in a pastebin and post here. I'll have a look Sunday (I'm on the road all day Saturday, sorry) if no one beats me to it.
reply
ok so i'm thinking of throwing more horsepower at the problem. need to get a new PC anyway so i'll just get an absolute juggernaut to process the pics 🤠 but mind if i contact you incase that doesn't work? can give you my email
reply