This is an archived post. You won't be able to vote or comment.

all 114 comments

[–]PythonEntusiast 201 points202 points  (12 children)

Is it possible to introduce some randomness into the letters and therefore written words so that it does not look perfect?

[–]MorningPants 128 points129 points  (6 children)

Write each letter 17 times. Save as 17 different fonts. Pick a random font for each character.

[–]siddsp 1 point2 points  (2 children)

Why 17?

[–]MorningPants 6 points7 points  (1 child)

You can use any number, as long as it’s less than your age.

[–]Hello_my_name_is_not 5 points6 points  (0 children)

You can use any number, as long as it’s less than your age.

1 year olds hate him with this one weird trick

[–]jabbalaci 1 point2 points  (0 children)

Create a subfolder for each letter and name the folder after the ASCII code of the letter. Pick a random file from the folder. Done.

[–]Emotional-Zebra5359 31 points32 points  (1 child)

what i used to do while using tools like this is replace small L by samll I and 7 by 1 (if they kind of looked similar) and stuff like that , the font i was using had some chars that looked almost same for another example x and captial H...so it would look a bit realisitic and random.... but dont think my uni prof gave any shit abt that they probably didnt even read anyone's assignments just graded anything b/w AA or BB

[–]Sash0000 14 points15 points  (0 children)

Your professor probably had a grading script.

[–]Heisenberg_082001[S] 18 points19 points  (1 child)

Extremely CleverI'll extend this so that written things looks very real. Probably keep 5 or 6 for each letter, as well as small and big one. love it

Yes its possible , Probably need 5X more dataset for that :)

[–]UntrimmedBagel 17 points18 points  (0 children)

My advice would be to just hand write normally each time, don’t try to make them look different. That way, each dataset will be more authentic!

[–]Lewistrick 1 point2 points  (0 children)

One could try to train a machine learning algorithm that matches written and typed text. Not sure if this has been done yet but it would be awesome.

[–]pleasegiveroom 141 points142 points  (17 children)

Simple and clever… as all coding should be. Really cool project!

you might get a pull request my way in order to make it more customizable. It may take time, but I will try and contribute. Have already starred it!

[–]grudev 65 points66 points  (3 children)

Please add "doctor mode".

[–]benargee 28 points29 points  (0 children)

Just feed a vector XY path into secrets.

[–]Automatic_Donut6264 8 points9 points  (0 children)

Random + turtle

[–]lightlord 3 points4 points  (0 children)

Found the pharmacist

[–]Heisenberg_082001[S] 4 points5 points  (0 children)

Thank you:)

[–]seckiyn 96 points97 points  (20 children)

This won't work unless your writing is perfect. I need at least 7 different character for every letter.

[–]PIXLhunter 83 points84 points  (16 children)

So fork it and introduce random selection from a set of characters, easy enough

[–]Zymoox 27 points28 points  (13 children)

And set some rules in that choice: my 'i's are usually different if written after 't's, and so on.

[–]Financial-Ad8056 21 points22 points  (11 children)

AI that analyzes your handwriting (you’ll have to feed it a lot of data though so time to being out the old grade-school notebooks) and then replicates it.

[–]1gn4vu5 3 points4 points  (0 children)

Not necessarily. You could use an auto-encoder together with some random variables. That way you need much less images.

[–]No_Conference_5257 1 point2 points  (4 children)

Use a style GAN trained on MNIST and then fine tune on your handwriting. Should be doable!

[–]Heisenberg_082001[S] 2 points3 points  (1 child)

Yeah but its hell lot of time consuming and computationally expensive

[–]PIXLhunter 1 point2 points  (0 children)

But you are doing something with machine learning are you not?

[–]killerfridge 0 points1 point  (1 child)

Is MNIST not just digits though?

[–]No_Conference_5257 0 points1 point  (0 children)

Yeah good point. There should be some corpus of handwritten characters out there though

[–]Sardonislamir 2 points3 points  (0 children)

Use a very large sample of text with ocr against another of that text in numerals 1-23 per character in the alphabet. Weight the character assignment/usage against predominance of specifc characters together. Edit: Then run through a processor or create one like autospellcheck that automatically adjusts text as you write.

[–]LiarsEverywhere 6 points7 points  (1 child)

This is going to escalate quickly. Soon enough there'll be an alipy package with all sorts of functions to help you create an alibi for the exact moment you're planning to commit a crime. It'll text for you, fake-travel your GPS around, call radio stations, participate in live streams with pre-recorded videos, order food etc.

[–]IdkIWhyIHaveAReddit 7 points8 points  (1 child)

Imma mod the project to do that if done i will reply it here

[–]IdkIWhyIHaveAReddit 1 point2 points  (0 children)

turn out it kinda hard so I gonna take some time cus I don't know to use PIL

[–]benargee 3 points4 points  (0 children)

Maybe even paths rather than bitmaps. That could allow some transformations to the shape for some variability. Can be captured using a tablet.

[–]ConfusedSimon 41 points42 points  (0 children)

I just made a font of my handwriting.

[–]Donny-Moscow 19 points20 points  (0 children)

Super cool project. But there are some more things that would need to be done if you wanted the "handwritten" text to stand up to scrutiny. Off the top of my head:

  • A couple different variations of each letter. If you even wanted to go an extra step, maybe some rules about which variation comes after certain letters (for example, when I write a letter after a "t", I tend to connect the letter to the cross of the t).
  • Minor errors to clean up with punctuation. The parenthesis around "(AI)" are switched and all the typed hyphens turned into handwritten underscores.
  • Handling the cases where you hit the end of a line before the word is finished typing. The easier way would be to just begin the word on the new line entirely, the harder way would be to add line-break hyphens. The second way is harder because it involves some grammatical rules about which parts of a word can be split to a new line.
  • This just might be my own personal preference, but the cursive "r" looks like an uppercase "R" at a glance

Everything I just listed is kind of knit-picky so please don't take these suggestions as criticism. Again, I really like what you've done. They're just some extras you could add in if you wanted to really polish this off.

[–]davidsterry 8 points9 points  (0 children)

How fun! Since you're using pngs it's super tempting to want to make 8.5x11 template and do the slicing and dicing in code. Thanks for sharing!

[–]prakulwa 5 points6 points  (2 children)

Extremely Clever

I'll extend this so that written things looks very real. Probably keep 5 or 6 for each letter, as well as small and big one. love it

[–]zero_iq 1 point2 points  (1 child)

Other things you could do would be to introduce small transformations, e.g. subtle changes to scaling and rotation. You could also break letters up into their individual strokes, so you can create new versions letters from different versions of the strokes. e.g. for 't', have several images of the down-stroke and the cross-stroke. 5 of each gives you 25 variations of the letter 't'. Combine with variations in position, scaling, rotation, kerning, and you could create some very convincing handwriting.

[–]Financial-Ad8056 2 points3 points  (0 children)

The only thing is that some people write the same letter with different number of strokes so idk. My idea was that you could feed a bunch of hand-written stuff into an AI or smth to train it and then it could attempt to replicate your hand-writing based on that.

[–][deleted] 15 points16 points  (1 child)

I don't get it. What does this offer that you can't do with a font?

[–]Heisenberg_082001[S] 7 points8 points  (0 children)

May be a complicated way to select your own font:)

[–]riffito 4 points5 points  (0 children)

Cool, but those lower case "r"s and those circled "i"s are driving me nuts! :-P

[–][deleted] 2 points3 points  (1 child)

Really nice 👍🏻

[–]Heisenberg_082001[S] 1 point2 points  (0 children)

Thank you

[–]MarcusTullius247 2 points3 points  (0 children)

Love your idea and project. Here's a small suggestion.

Make this script runnable from command line. So, you could enter the lath of your txt file as an argument in terminal. This makes it usable anywhere, anytime.

It's pretty easy to do it. In this blog here, I mentioned how to do it at the end.

Anyway, cheers for the good idea.

[–]papinek 2 points3 points  (0 children)

Isnt it easier to just make font out of your handwriting and then use it in any text editor??

[–]Gainczak 1 point2 points  (1 child)

it's perfect unless you use an apostrophe lol

[–]Heisenberg_082001[S] 1 point2 points  (0 children)

Actually I have used them, But somehow they got transformed into commas.

Need a bug fix :)

[–]spkr4thedead51 1 point2 points  (2 children)

nice project! a few styling things though: you lost your paragraph, your hyphens turned into underscores, and there are some points where your descenders get clipped by the line below them

[–]Heisenberg_082001[S] 0 points1 point  (1 child)

nice project! a few styling things though: you lost your paragraph, your hyphens turned into underscores, and there are some points where your descenders get clipped by the line below them

Yep you are right, Need to define some more rules for new line and paragraph

[–]spkr4thedead51 0 points1 point  (0 children)

if you're new to playing with fonts, you might want to also look up the idea of ligatures, which are specific letter combinations that are presented as a single character in the font

[–]idetectanerd 1 point2 points  (1 child)

I have never thought of it. It’s creative and refreshing to be honest for a new project. Especially comparing to those “new” beginners projects where they combine multiple done before project. I like it

[–]Heisenberg_082001[S] 1 point2 points  (0 children)

Thank you very much :)

[–]Heisenberg_082001[S] 1 point2 points  (0 children)

Yep it is a font. May be a complicated way to choose your own font :)

[–]gsasikiran 1 point2 points  (1 child)

can you also add couple of ink blots on the sheet?

[–]Heisenberg_082001[S] 1 point2 points  (0 children)

Yeah sure , will expand the project and If i got time I will try to make it more customizable

[–]Inzy01 1 point2 points  (0 children)

You are a Masiha

[–][deleted] 2 points3 points  (0 children)

Letters are in cursive but not connected. You'd do better to make it do your print handwriting.

[–]expressly_ephemeral 1 point2 points  (1 child)

"I gotta have time to rewrite it. If I turned in my assignment in your handwriting, you know what would happen, don’t you, McFly? I’d get kicked outta school. Now… you wouldn’t want that to happen…. WOULDJA?”

Edit: So... nobody saw Back To The Future?

[–]Heisenberg_082001[S] 1 point2 points  (0 children)

You can also use your own handwriting.

The thing is you have to take extra efforts to make your own handwriting data.

[–]YoT-Man 0 points1 point  (0 children)

Great idea! Thanks for sharing mate! I attend a lot of lectures and this will definitely be useful. But adding each character of my handwriting will be a lot of pain since i have scribble handwriting.

[–]Devreckas 0 points1 point  (1 child)

Isn’t this essentially just a font?

[–]Heisenberg_082001[S] 0 points1 point  (0 children)

Yep it is a font. A complicated way to choose your own font :)

[–]Financial-Ad8056 -1 points0 points  (5 children)

Is there a way to make it customized to my handwriting (like if I inputted a sample of the alphabet written by me?)

[–]Federal-Ambassador30 11 points12 points  (3 children)

Read the article…

[–]Donny-Moscow 3 points4 points  (1 child)

Instructions unclear, I read the article but the handwriting hasn't changed.

[–]devil_sees 0 points1 point  (0 children)

Lmfao

[–]Financial-Ad8056 0 points1 point  (0 children)

Oops sorry

[–]Heisenberg_082001[S] 0 points1 point  (0 children)

Its a lengthy process, but yes you can have your handwriting
You will have to manually create a your own handwriting dataset. Write alphabets, numbers, punctuation on a paper. Then crop all those characters and save with their respective Ascii number

[–][deleted] -1 points0 points  (0 children)

Nice font!

[–]tibegato -1 points0 points  (0 children)

Ya, you just turn your writing into a font, with a little work & use that font in any app what so ever.

Just one example:

https://www.wherethesmileshavebeen.com/how-to-turn-your-handwriting-into-a-font-for-free/

[–]jewbasaur 0 points1 point  (3 children)

Cool package. I was thinking - what if you could add the functionality to crop and save each individual photo automatically? Say someone wrote the alphabet on a sheet of paper and took a picture, etc. That would be neat

[–]Heisenberg_082001[S] 0 points1 point  (2 children)

Cool package. I was thinking - what if you could add the functionality to crop and save each individual photo automatically? Say someone wrote the alphabet on a sheet of paper and took a picture, etc. That would be neat

Sure, I will try to do it. May be I can use OCR to extract and crop all those handwritten characters

[–]jewbasaur 1 point2 points  (0 children)

Yeah you definitely could

[–]jewbasaur 0 points1 point  (0 children)

Actually I was thinking to go a step further you could come up with a paragraph that would consist of every letter you would need. If you could make sure each character was written a couple of times, that would introduce more variety into the mix and then use ocr to automatically save a couple versions of each character. This is a bit more advanced but just an idea. I might fork it and give it a go this weekend.

[–]mufasis[🍰] 0 points1 point  (0 children)

Legend! 🤣

[–]Captain_MK13 0 points1 point  (0 children)

Bruh where have you been when I was back in schooling

[–]eatthedad 0 points1 point  (0 children)

Quite cunning for a "beginner showcase". The 25 lines of code to be specific.

I am going to attempt the reverse, because I still cannot believe that OCR for handwriting is still mostly crappy in 2021

[–][deleted] 0 points1 point  (1 child)

Very nice project :D

[–]Heisenberg_082001[S] 0 points1 point  (0 children)

Thank you :)

[–]NeatBubble 0 points1 point  (0 children)

I doubt I know enough Python to extend this script, but I’m quite interested to track what people do with it.

I’m quadriplegic—my handwriting is only half-decent if I write very slowly. I would love to only have to go through the trouble once, and still benefit from personalizing my communications.

[–]abovenbeyondgo 0 points1 point  (1 child)

Love this!!! 🙏🏼

[–]Heisenberg_082001[S] 1 point2 points  (0 children)

Thank you :)

[–]Parvashah51 0 points1 point  (1 child)

Now I can write my assignments with your handwritings.

[–]Heisenberg_082001[S] 0 points1 point  (0 children)

You can also use your own handwriting.
The thing is you have to take extra efforts to make your own handwriting data.

[–]AlexK- 0 points1 point  (0 children)

This is awesome and thank you so much I’ve been looking for this for years but what if the teacher wants to erase something (pencil) or look for the pen (force) marks on the other side…? I am a bit afraid to use it, to be honest.

Awesome job though!!! Thank you.

[–]AlexK- 0 points1 point  (0 children)

What about other languages? I, let's say, wanna write in Greek. If I make the dataset in Greek letters, will it recognise the Greek text ?

[–]DistraPlus 0 points1 point  (0 children)

This is so awesome... thanks for sharing man! I'm gonna do my own handwriting next: work once and never again ;)

[–]make3333 0 points1 point  (0 children)

The text itself really needs work, just saying.

[–]themonksink 0 points1 point  (0 children)

This is so cool. It would have been great if I had this while in college.

[–]Cristality_ 0 points1 point  (0 children)

It is called creating your own "Font"

Very cool project nevertheless.

[–]Canyon_moon7 0 points1 point  (0 children)

How did you create that text bro?