Skip to content

Commit

Permalink
Small updates to Gradio cookbook (#894)
Browse files Browse the repository at this point in the history
Small updates to Gradio cookbook
  • Loading branch information
saqadri authored Jan 11, 2024
2 parents f170d8c + d48f5af commit 0ab5244
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
25 changes: 17 additions & 8 deletions cookbooks/Gradio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ What you see here is a "local editor" -- a React frontend and a Flask server whi

- [Backend server code](https://github.com/lastmile-ai/aiconfig/tree/main/python/src/aiconfig/editor/server)

### Supported Hugging Face tasks

We have started by supporting the 6 most popular Hugging Face tasks (by number of models). We will open up contributions for other tasks from the community, and also progressively add support for more ourselves. Currently supported with **Transformers** and **Diffusers**:

- image-to-text
- text-to-image
- asr (automatic speech recognition)
- text generation
- text summarization
- text translation

In addition we support the following **HF inference API**:

- text generation

### Gradio custom component

The Gradio custom component is currently WIP.
Expand All @@ -31,7 +46,7 @@ We are working on using `sveltris` to package our React frontend to work with Gr
**Instructions**:

- Clone https://github.com/lastmile-ai/aiconfig
- Go back to top-level directory: `cd <aiconfig>`
- Go to top-level directory: `cd <aiconfig>`

- `cd <aiconfig>/cookbooks/Gradio`

Expand All @@ -40,17 +55,11 @@ We are working on using `sveltris` to package our React frontend to work with Gr
- Install `python-aiconfig-test` package from `test-pypi`:

```
pip3 install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple python-aiconfig-test==1.1.30 --force
pip3 install --index-url https://test.pypi.org/simple --extra-index-url https://pypi.org/simple python-aiconfig-test==1.1.38 --force
```

Now run this command to start the AIConfig editor:

```bash
aiconfig edit --aiconfig-path=huggingface.aiconfig.json --parsers-module-path=hf_model_parsers.py
```

## TODO

- Publish new version of aiconfig_extension_hugging_face package
- Update huggingface.aiconfig.json with clean examples
- Add video demo
6 changes: 6 additions & 0 deletions cookbooks/Gradio/hf_model_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
HuggingFaceTextTranslationTransformer,
)

from aiconfig_extension_hugging_face.remote_inference_client.text_generation import HuggingFaceTextGenerationParser

from aiconfig import AIConfigRuntime


Expand All @@ -31,3 +33,7 @@ def register_model_parsers() -> None:
AIConfigRuntime.register_model_parser(text_summarization, text_summarization.id())
text_translation = HuggingFaceTextTranslationTransformer()
AIConfigRuntime.register_model_parser(text_translation, text_translation.id())

# Register remote inference client for text generation
text_generation_remote = HuggingFaceTextGenerationParser()
AIConfigRuntime.register_model_parser(text_generation_remote, text_generation_remote.id())
5 changes: 3 additions & 2 deletions cookbooks/Gradio/huggingface.aiconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
"input": {
"attachments": [
{
"data": "./hi.mp3",
"data": "https://s3.amazonaws.com/lastmileai.aiconfig.public/uploads/2024_1_11_20_34_32/3386/hi.mp3",
"mime_type": "audio/mpeg"
}
]
Expand All @@ -220,7 +220,8 @@
}
},
"parameters": {}
}
},
"outputs": []
}
],
"$schema": "https://json.schemastore.org/aiconfig-1.0"
Expand Down
4 changes: 2 additions & 2 deletions cookbooks/Gradio/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AIConfig
python-aiconfig
python-aiconfig >= 1.1.12

# Hugging Face Extension for AIConfig
aiconfig-extension-hugging-face >= 0.0.2
aiconfig-extension-hugging-face >= 0.0.3

0 comments on commit 0ab5244

Please sign in to comment.