File size: 996 Bytes
45f4319 ba909aa 2d12939 4b868e7 14bbb6a 45f4319 ba909aa 9099785 45f4319 4b38a82 45f4319 4b38a82 458314b 3076b95 b525a91 45f4319 553b6b3 2d12939 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import json
import copy
import gradio as gr
import tensorflow as tf
import tensorflow_text
from tensorflow.python.saved_model import tag_constants
from huggingface_hub import Repository
from pingpong import PingPong
from pingpong.gradio import GradioAlpacaChatPPManager
from pingpong.context import CtxLastWindowStrategy
local_path = "hf_model"
model_version = "v1687590401"
model_repo_id = "chansung/kerasnlp-gpt2-alpaca-pipeline"
model_repo_url = f"https://huggingface.co/{model_repo_id}"
def _clone_and_checkout(repo_url: str, local_path: str, version: str) -> Repository:
repository = Repository(
local_dir=local_path, clone_from=repo_url
)
repository.git_checkout(revision=version)
return repository
_ = _clone_and_checkout(model_repo_url, local_path, model_version)
model = tf.saved_model.load(local_path, tags=[tag_constants.SERVING])
# gpt_lm_predict_fn = model.signatures["serving_default"]
with gr.Blocks() as demo:
gr.Markdown("Hello")
demo.launch() |