Skip to content

Commit

Permalink
Add Remote Inference Parsers to Gradio Cookbook Parser Registry (#1223)
Browse files Browse the repository at this point in the history
# Add Remote Inference Parsers to Gradio Cookbook Parser Registry

Was getting annoyed of manually updating this to test the remote parsers
each time. Just copied registration from what we do in Gradio and did a
quick check a few worked

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/1223).
* __->__ #1223
* #1222
* #1221
  • Loading branch information
rholinshead authored Feb 13, 2024
2 parents 9b49d85 + 06a1d80 commit dfbe26a
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions cookbooks/Gradio/aiconfig_model_registry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Local Model Inference
from aiconfig_extension_hugging_face import (
HuggingFaceAutomaticSpeechRecognitionTransformer,
HuggingFaceImage2TextTransformer,
Expand All @@ -7,8 +8,16 @@
HuggingFaceTextSummarizationTransformer,
HuggingFaceTextTranslationTransformer,
)
from aiconfig_extension_hugging_face.remote_inference_client.text_generation import (

# Remote Inference
from aiconfig_extension_hugging_face import (
HuggingFaceAutomaticSpeechRecognitionRemoteInference,
HuggingFaceImage2TextRemoteInference,
HuggingFaceText2ImageRemoteInference,
HuggingFaceText2SpeechRemoteInference,
HuggingFaceTextGenerationRemoteInference,
HuggingFaceTextSummarizationRemoteInference,
HuggingFaceTextTranslationRemoteInference,
)

from aiconfig import AIConfigRuntime
Expand Down Expand Up @@ -46,7 +55,39 @@ def register_model_parsers() -> None:
)

# Register remote inference client for text generation
automatic_speech_recognition_remote = (
HuggingFaceAutomaticSpeechRecognitionRemoteInference()
)
AIConfigRuntime.register_model_parser(
automatic_speech_recognition_remote, "Automatic Speech Recognition"
)

image_to_text_remote = HuggingFaceImage2TextRemoteInference()
AIConfigRuntime.register_model_parser(
image_to_text_remote, "Image-to-Text"
)

text_to_image_remote = HuggingFaceText2ImageRemoteInference()
AIConfigRuntime.register_model_parser(
text_to_image_remote, "Text-to-Image"
)

text_to_speech_remote = HuggingFaceText2SpeechRemoteInference()
AIConfigRuntime.register_model_parser(
text_to_speech_remote, "Text-to-Speech"
)

text_generation_remote = HuggingFaceTextGenerationRemoteInference()
AIConfigRuntime.register_model_parser(
text_generation_remote, text_generation_remote.id()
text_generation_remote, "Text Generation"
)

text_summarization_remote = HuggingFaceTextSummarizationRemoteInference()
AIConfigRuntime.register_model_parser(
text_summarization_remote, "Summarization"
)

text_translation_remote = HuggingFaceTextTranslationRemoteInference()
AIConfigRuntime.register_model_parser(
text_translation_remote, "Translation"
)

0 comments on commit dfbe26a

Please sign in to comment.