Skip to content

Commit

Permalink
Fix model name to model link conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamanehSaadat committed Apr 19, 2024
1 parent 71f2718 commit 3a0effe
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion keras_nlp/utils/preset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import inspect
import json
import os
import re

from absl import logging

Expand Down Expand Up @@ -335,6 +336,11 @@ def _validate_backbone(preset):
)


def get_snake_case(name):
name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", name)
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower()


def create_model_card(preset):
model_card_path = os.path.join(preset, README_FILE)
markdown_content = ""
Expand Down Expand Up @@ -364,7 +370,9 @@ def create_model_card(preset):
markdown_content += "pipeline_tag: text-classification\n"
markdown_content += "---\n"

model_link = f"https://keras.io/api/keras_nlp/models/{model_name.lower()}"
model_link = (
f"https://keras.io/api/keras_nlp/models/{get_snake_case(model_name)}"
)
markdown_content += (
f"This is a [`{model_name}` model]({model_link}) "
"uploaded using the KerasNLP library.\n"
Expand Down

0 comments on commit 3a0effe

Please sign in to comment.