sjvasquez / handwriting-synthesis

Handwriting Synthesis with RNNs ✏️
4.27k stars 568 forks source link

creating your own style? #70

Open FergalHennessy opened 1 year ago

FergalHennessy commented 1 year ago

is there a script that allows us to create our own style files from drawing, or a link to the program that was used to generate them? ^_^

iso2013 commented 1 year ago

You'd need to train your own model, as described here: https://github.com/sjvasquez/handwriting-synthesis/tree/master/data/raw

FergalHennessy commented 1 year ago

You'd need to train your own model, as described here: https://github.com/sjvasquez/handwriting-synthesis/tree/master/data/raw

is this true? looking at the code it seems the style files are just regular x files, and that the output is generated using the priming method, which means you can use the pretrained model

Tombstone2K commented 11 months ago

You'd need to train your own model, as described here: https://github.com/sjvasquez/handwriting-synthesis/tree/master/data/raw

That just tells us about training the model on presumably the same dataset. Is there any resource to process my own handwriting to be able to generate that.

Or like @FergalHennessy mentioned can we use the pretrained model with our own handwriting

acmattson3 commented 9 months ago

is there a script that allows us to create our own style files from drawing, or a link to the program that was used to generate them? ^_^

I'm searching for such a script myself. I attempted to create one but couldn't figure out how to replicate the format of the .npy files in the styles directory. I am able to train my data using rnn.py after having reverse engineered the prepare_data.py script but the format between the training data files and the style files seems drastically different, at least for the character data. Stroke data seems to be the same, actually.

Fardenco commented 9 months ago

I'm interested as well

DrakeHooks commented 8 months ago

is there a script that allows us to create our own style files from drawing, or a link to the program that was used to generate them? ^_^

I'm searching for such a script myself. I attempted to create one but couldn't figure out how to replicate the format of the .npy files in the styles directory. I am able to train my data using rnn.py after having reverse engineered the prepare_data.py script but the format between the training data files and the style files seems drastically different, at least for the character data. Stroke data seems to be the same, actually.

Were you ever able to find this? I want to train a model with my own handwriting.

acmattson3 commented 8 months ago

this

I got a rudimentary script from someone who managed to get it to work. I haven't looked at it yet as I haven't had the time. Here is where it is posted.

sah1lga1kwad commented 6 months ago

Is it possible that using this Repo - I can upload 20-30 pages of my own handwriting and this code then can write in that particular style?

acmattson3 commented 6 months ago

Is it possible that using this Repo - I can upload 20-30 pages of my own handwriting and this code then can write in that particular style?

I never found an easy way to do this, so I just built it myself. It's not perfect but it gets the job done. You just write ~800 "prompts" (~70 characters each) and train the model.

I tried it myself and got close (becoming too lazy to write any more), but one person (who you can find in the issues of that repo) managed to get an impressive result.

techno-yogi commented 3 months ago

Do you know if the drawing board you used is compatible with android tablet? Like if I ran the python code on android directly I wonder if this would be compatible with stylus to make it better handwriting for the prompts

ImNotOssy commented 3 months ago

Do you know if the drawing board you used is compatible with android tablet? Like if I ran the python code on android directly I wonder if this would be compatible with stylus to make it better handwriting for the prompts

What i originally tried was using my s24 ultra spen. Samsung has this little beta feature thats hidden where you can make your device a wireless display for your PC. I used that and started to draw using my SPEN, i noticed my screen was too small to be able to do it correctly so i just went ahead and bought a Gaomon drawing tablet (im returning it after im done). Im sure you could use an samsung table with an spen it would be big enough.

acmattson3 commented 3 months ago

Do you know if the drawing board you used is compatible with android tablet? Like if I ran the python code on android directly I wonder if this would be compatible with stylus to make it better handwriting for the prompts

What i originally tried was using my s24 ultra spen. Samsung has this little beta feature thats hidden where you can make your device a wireless display for your PC. I used that and started to draw using my SPEN, i noticed my screen was too small to be able to do it correctly so i just went ahead and bought a Gaomon drawing tablet (im returning it after im done). Im sure you could use an samsung table with an spen it would be big enough.

I just created this web-based handwriting data maker that works on touch devices. It is crude, but gets the job done. See my handwriting data repository for more information on how to use it. Please raise an issue on the repository if you see any glaring problems or important things to add.

ImNotOssy commented 3 months ago

Do you know if the drawing board you used is compatible with android tablet? Like if I ran the python code on android directly I wonder if this would be compatible with stylus to make it better handwriting for the prompts

What i originally tried was using my s24 ultra spen. Samsung has this little beta feature thats hidden where you can make your device a wireless display for your PC. I used that and started to draw using my SPEN, i noticed my screen was too small to be able to do it correctly so i just went ahead and bought a Gaomon drawing tablet (im returning it after im done). Im sure you could use an samsung table with an spen it would be big enough.

I just created this web-based handwriting data maker that works on touch devices. It is crude, but gets the job done. See my handwriting data repository for more information on how to use it. Please raise an issue on the repository if you see any glaring problems or important things to add.

This would have been so useful couple days ago. Sadly I'm past this step, currently struggling with implementing the training step on Google colab. I had it working a couple hours ago but it was using the cpu rather than the gpu and then it broke and I gave up for now.

ImNotOssy commented 3 months ago

Finally got it to work, after a long time editing the code and i was finally able to fully complete a training session with the little data i made using the prompts. Im now getting errors trying to run the demo.py with my data, mismatched shapes. The error message indicates that the parameter shape is [1, 20, 2] and the flat indices being accessed are [0, 20], which is out of bounds. I dont know what im doing. :)

acmattson3 commented 3 months ago

Finally got it to work, after a long time editing the code and i was finally able to fully complete a training session with the little data i made using the prompts. Im now getting errors trying to run the demo.py with my data, mismatched shapes. The error message indicates that the parameter shape is [1, 20, 2] and the flat indices being accessed are [0, 20], which is out of bounds. I dont know what im doing. :)

I found that the model can error out like that if you don't have enough data. I needed a couple hundred. It needs enough examples of each letter. That might work for you.

ImNotOssy commented 3 months ago

Finally got it to work, after a long time editing the code and i was finally able to fully complete a training session with the little data i made using the prompts. Im now getting errors trying to run the demo.py with my data, mismatched shapes. The error message indicates that the parameter shape is [1, 20, 2] and the flat indices being accessed are [0, 20], which is out of bounds. I dont know what im doing. :)

I found that the model can error out like that if you don't have enough data. I needed a couple hundred. It needs enough examples of each letter. That might work for you.

thank you so much, yeah i figured, im working on writing more prompts using your work. Im confused, after this how will i be able to generate my own "style" i looked into the script you quoted above but i dont really understand it.

acmattson3 commented 3 months ago

thank you so much, yeah i figured, im working on writing more prompts using your work. Im confused, after this how will i be able to generate my own "style" i looked into the script you quoted above but i dont really understand it.

You won't need to use a style if you are making your own data. The README in my handwriting data directory walks through how to do it with your own data without styles.

ImNotOssy commented 3 months ago

thank you so much, yeah i figured, im working on writing more prompts using your work. Im confused, after this how will i be able to generate my own "style" i looked into the script you quoted above but i dont really understand it.

You won't need to use a style if you are making your own data. The README in my handwriting data directory walks through how to do it with your own data without styles.

thanks you've been such good help. I'll present my findings after i finish my prompts.

ImNotOssy commented 2 months ago

thank you so much, yeah i figured, im working on writing more prompts using your work. Im confused, after this how will i be able to generate my own "style" i looked into the script you quoted above but i dont really understand it.

You won't need to use a style if you are making your own data. The README in my handwriting data directory walks through how to do it with your own data without styles.

Have you tried looking into style creation using your program to generate an svg file and the the style npy? I find it harder to train the AI then to create a style suitable for the pre trained model. I'm having little to no luck trying this. Wanted to know if you tried anything before, could help me.

acmattson3 commented 2 months ago

thank you so much, yeah i figured, im working on writing more prompts using your work. Im confused, after this how will i be able to generate my own "style" i looked into the script you quoted above but i dont really understand it.

You won't need to use a style if you are making your own data. The README in my handwriting data directory walks through how to do it with your own data without styles.

Have you tried looking into style creation using your program to generate an svg file and the the style npy? I find it harder to train the AI then to create a style suitable for the pre trained model. I'm having little to no luck trying this. Wanted to know if you tried anything before, could help me.

I could never figure out the data format, hence why I am training the model from scratch. Styles only minorly change the handwriting, so if you want an accurate copy they're not the way to go. But if you want quick and dirty and "that kinda looks like my handwriting" styles would be fine (if I could figure them out).

krih commented 3 weeks ago

thank you so much, yeah i figured, im working on writing more prompts using your work. Im confused, after this how will i be able to generate my own "style" i looked into the script you quoted above but i dont really understand it.

You won't need to use a style if you are making your own data. The README in my handwriting data directory walks through how to do it with your own data without styles.

Have you tried looking into style creation using your program to generate an svg file and the the style npy? I find it harder to train the AI then to create a style suitable for the pre trained model. I'm having little to no luck trying this. Wanted to know if you tried anything before, could help me.

I could never figure out the data format, hence why I am training the model from scratch. Styles only minorly change the handwriting, so if you want an accurate copy they're not the way to go. But if you want quick and dirty and "that kinda looks like my handwriting" styles would be fine (if I could figure them out).

I looked at your repository and website. You display a model of your handwriting that you indicated did not have enough data and so it was not yet legible, but I didn't see a successfully generated example using your handwriting. Did you get it to become legible? Also, do you have any pre-trained models if someone were to want to play around with it prior to writing hundreds of prompts? The handwriting synthesis model on this repository largely does what I want it to, but I am dissatisfied with its generation of numbers and symbols.

Subhan-Zaheer commented 2 weeks ago

Can Any one tell that how can I train model for one style?

ImNotOssy commented 2 weeks ago

Can Any one tell that how can I train model for one style?

lots and lots of prompt training

Subhan-Zaheer commented 2 weeks ago

Can Any one tell that how can I train model for one style?

lots and lots of prompt training

Can you please explain a bit more.

Like If I want to train the model for only style-9 how can I do that ?

Subhan-Zaheer commented 2 weeks ago

Can Any one tell that how can I train model for one style?

lots and lots of prompt training

Can you please explain a bit more.

Like If I want to train the model for only style-9 how can I do that ?

Moreover, I have some other question, if someone can answer.

To generate one new handwriting style, is the model trained on data from a single handwriting author or is data from multiple authors used?

ImNotOssy commented 2 weeks ago

Can Any one tell that how can I train model for one style?

lots and lots of prompt training

Can you please explain a bit more. Like If I want to train the model for only style-9 how can I do that ?

Moreover, I have some other question, if someone can answer.

To generate one new handwriting style, is the model trained on data from a single handwriting author or is data from multiple authors used?

this works different ways, the model was trained in a database of many various handwriting authors, from that the model learned how to write. then there is style priming where you create a style and try to generate handwriting to match the style you want (i haven't figured out how to do that).

The way i've been using it is by trying to match my own personal handwriting style, and for that all i need to do is train the model on only prompts written in my handwriting and naturally the model will match my style without the need of any other style priming.

to train the model on only a certain style that's already provided inside is possible but hard, you first have to find which author in the database was the handwriting style derived from and then train the model but that is too much of a tedious task. just using the style as is should grant "good enough" results. There are some characters and symbols that the model was not trained in. AS well as sequences of letters and numbers like the number 75227 for example. the only way to fix this is to retrain the model and making sure to include some examples of it in your prompts.

Subhan-Zaheer commented 2 weeks ago

Can Any one tell that how can I train model for one style?

lots and lots of prompt training

Can you please explain a bit more. Like If I want to train the model for only style-9 how can I do that ?

Moreover, I have some other question, if someone can answer. To generate one new handwriting style, is the model trained on data from a single handwriting author or is data from multiple authors used?

this works different ways, the model was trained in a database of many various handwriting authors, from that the model learned how to write. then there is style priming where you create a style and try to generate handwriting to match the style you want (i haven't figured out how to do that).

The way i've been using it is by trying to match my own personal handwriting style, and for that all i need to do is train the model on only prompts written in my handwriting and naturally the model will match my style without the need of any other style priming.

to train the model on only a certain style that's already provided inside is possible but hard, you first have to find which author in the database was the handwriting style derived from and then train the model but that is too much of a tedious task. just using the style as is should grant "good enough" results. There are some characters and symbols that the model was not trained in. AS well as sequences of letters and numbers like the number 75227 for example. the only way to fix this is to retrain the model and making sure to include some examples of it in your prompts.

Thank you so much for all the information. So kind of you.

Can you please just guide me on certain other things. Like as you said, to train model on specific style that's already inside, we have to find out that which author's handwriting style derived from. So, I want to ask that how can I get this information. Because in dataset we do have writer id and information, line strokes, word id, character id but there is no information about which author handwriting or word or character is used for which style. (Let's say for style-9 how many words and characters and how many (which) authors are there as no information about style is provided in dataset, according to my knowledge : ( )