There are typically two main factors that sway a judge to one side. You can use physical evidence or witness testimony to showcase your innocence to a judge. Before a trial begins, gather any evidence you can that may exonerate you of wrongdoing and talk to witnesses who can corroborate your side of the story.
Ultimately, having the right attorney who can present your case well may be the difference between a guilty and not guilty verdict.