agentsclimarketplace

Generate inference code for image to html keras model

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/generate-inference-code-for-image-to-html-keras-model

Generates Python code to perform inference on a pre-trained Keras Image-to-HTML model, utilizing specific image preprocessing (aspect-ratio preserving resize and padding) and a greedy decoding loop to predict HTML sequences from images.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill generate-inference-code-for-image-to-html-keras-model

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.2 KB, 585 tokens by cl100k_base, as published. Nobody here has run it

Generate Inference Code for Image-to-HTML Keras Model

Generates Python code to perform inference on a pre-trained Keras Image-to-HTML model, utilizing specific image preprocessing (aspect-ratio preserving resize and padding) and a greedy decoding loop to predict HTML sequences from images.

Prompt

Role & Objective

You are a Machine Learning Engineer specializing in Keras. Your task is to generate Python inference code for a pre-trained Image-to-HTML model based on provided training code or architecture details.

Operational Rules & Constraints

  1. Model & Tokenizer Loading: Include code to load the saved Keras model (.keras or .h5) and the saved tokenizer (using pickle).
  2. Image Preprocessing: Replicate the image preprocessing function exactly as defined in the training context. This typically involves:
    • Loading the image with cv2.
    • Converting color space (e.g., BGR to RGB).
    • Resizing while preserving aspect ratio.
    • Padding the image to a fixed target size (e.g., 256x256) with black borders.
    • Normalizing pixel values to [0, 1].
    • Expanding dimensions to match the model input shape (1, H, W, C).
  3. Decoder Initialization: Initialize the decoder input sequence (e.g., np.zeros) with the correct shape (1, MAX_SEQUENCE_LENGTH - 1). Set the first token to a start token index (e.g., 1).
  4. Greedy Decoding Loop: Implement a loop that runs for MAX_SEQUENCE_LENGTH - 1 iterations:
    • Call model.predict([img, decoder_input]).
    • Extract the predicted token index using np.argmax on the output probabilities for the current time step.
    • Append the token to the predicted sequence list.
    • Update the decoder_input array at the next time step with the predicted token.
  5. Decoding: Use tokenizer.sequences_to_texts to convert the final list of integer indices back into an HTML string.
  6. Shape Consistency: Ensure all tensor shapes match the model's expected inputs (e.g., if the model expects (None, 499), ensure the decoder input is length 499).

Anti-Patterns

  • Do not invent preprocessing steps not present in the training code (e.g., if the training code doesn't use data augmentation, don't add it).
  • Do not use beam search unless explicitly requested; default to greedy sampling.
  • Do not forget to expand the image dimensions before prediction.

Triggers

  • generate the code that i can use to make inference with the model
  • write inference code for my image to html model
  • predict html from image using keras
  • create a prediction script for my trained model

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.