Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Step by step guide to help users get Deep Font Recogition working. #3

Open
LinuxBeaver opened this issue Apr 10, 2021 · 3 comments
Open

Comments

@LinuxBeaver
Copy link

Hello, I am not a computer science person, but I have interest in having an offline usable image to font detection app on my computer. If there was a instruction guide to show users how to setup this program, it would be very helpful.

For example, I have "Font_Rec(DeepFont).ipynb" opened inside Jupyter Notebook but I don't know what to do to get things going.
Where do I upload the unknown font image? And do I need to give the the program these libraries to get it working? My goal is to have an offline usable font detection app.
CopyQ TT2782

@nissansz
Copy link

nissansz commented May 4, 2023

Have you figured it out?

@Eric-WK
Copy link

Eric-WK commented Nov 27, 2023

Hi both,

I got the notebook up and running. I'm in the midst of expanding the dataset as mentioned in the README.

The steps to get it running is the following:

  1. Clone the repository into your google drive (you can do it via the notebook by running git clone with either the http or ssh url.

  2. In my case you needed to comment out the following line: from keras.layers.normalization import BatchNormalization and replace it with from tensorflow.keras.layers import BatchNormalization

  3. make sure your current working directory is the same as where the notebook is contained. i.e. you can place this under the Preparing Dataset header: NOTEBOOK_DIR = <path/to/DeepFont> if os.getcwd() != NOTEBOOK_DIR: os.chdir(NOTEBOOK_DIR) print(os.getcwd()) print(os.listdir())

  4. Before running the model, you need to switch out the optimizer, in this case Stochastic Gradient Descent (SGD) for the legacy one. Replace this line: sgd = optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) with the following: sgd = tf.keras.optimizers.legacy.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True). Make sure to import the followingimport tensorflow as tf, for the legacy SGD to work as it is under tf.keras now.

  5. Then you can train the model and have it running with no problem.

  6. The training path, i.e. the images used for training is a subset of the original, so you can expand it, or place your own custom fonts in there, which is located at font_patch/

  7. The test image, is the variable called img_path, make sure to include the correct path to the image.

  8. you can replace the class_predictions or y with the following: import numpy as np predictions = model.predict(data) class_predictions = np.argmax(predictions, axis=-1)

  9. The plotting will then be: label = rev_conv_label(int(class_predictions[0])) fig, ax = plt.subplots(1) ax.imshow(pil_im, interpolation='nearest', cmap=cm.gray) ax.text(5, 5, label , bbox={'facecolor': 'white', 'pad': 10}) plt.show()

Hope this helps!

@MohammedMusadiq
Copy link

Hi @Eric-WK
can you guide me how you generated the dataset.
If it's ok with you, can you share the code.
Thank you in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants