mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
Add docs for HF Json saver (#3604)
* Add docs for flagging * Fix params * CHANGELOG --------- Co-authored-by: freddyaboulton <alfonsoboulton@gmail.com>
This commit is contained in:
parent
c9b8a0c484
commit
cecd5a2526
@ -17,9 +17,9 @@
|
||||
## Documentation Changes:
|
||||
|
||||
- Makes some fixes to the Theme Guide related to naming of variables, by [@abidlabs](https://github.com/abidlabs) in [PR 3561](https://github.com/gradio-app/gradio/pull/3561)
|
||||
- Documented `HuggingFaceDatasetJSONSaver` by [@osanseviero](https://github.com/osanseviero) in [PR 3604](https://github.com/gradio-app/gradio/pull/3604)
|
||||
- Makes some additions to documentation of `Audio` and `State` components, and fixes the `pictionary` demo by [@abidlabs](https://github.com/abidlabs) in [PR 3611](https://github.com/gradio-app/gradio/pull/3611)
|
||||
|
||||
|
||||
## Testing and Infrastructure Changes:
|
||||
|
||||
- Removed heavily-mocked tests related to comet_ml, wandb, and mlflow as they added a significant amount of test dependencies that prevented installation of test dependencies on Windows environemnts. By [@abidlabs](https://github.com/abidlabs) in [PR 3608](https://github.com/gradio-app/gradio/pull/3608)
|
||||
|
@ -365,14 +365,24 @@ class HuggingFaceDatasetSaver(FlaggingCallback):
|
||||
return line_count
|
||||
|
||||
|
||||
@document()
|
||||
class HuggingFaceDatasetJSONSaver(FlaggingCallback):
|
||||
"""
|
||||
A FlaggingCallback that saves flagged data to a Hugging Face dataset in JSONL format.
|
||||
A callback that saves flagged data (both the input and output data)
|
||||
to a Hugging Face dataset in JSONL format.
|
||||
|
||||
Each data sample is saved in a different JSONL file,
|
||||
allowing multiple users to use flagging simultaneously.
|
||||
Saving to a single CSV would cause errors as only one user can edit at the same time.
|
||||
|
||||
Example:
|
||||
import gradio as gr
|
||||
hf_writer = gr.HuggingFaceDatasetJSONSaver(HF_API_TOKEN, "image-classification-mistakes")
|
||||
def image_classifier(inp):
|
||||
return {'cat': 0.3, 'dog': 0.7}
|
||||
demo = gr.Interface(fn=image_classifier, inputs="image", outputs="label",
|
||||
allow_flagging="manual", flagging_callback=hf_writer)
|
||||
Guides: using_flagging
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@ -384,17 +394,12 @@ class HuggingFaceDatasetJSONSaver(FlaggingCallback):
|
||||
verbose: bool = True,
|
||||
):
|
||||
"""
|
||||
Params:
|
||||
hf_token (str): The token to use to access the huggingface API.
|
||||
dataset_name (str): The name of the dataset to save the data to, e.g.
|
||||
"image-classifier-1"
|
||||
organization (str): The name of the organization to which to attach
|
||||
the datasets. If None, the dataset attaches to the user only.
|
||||
private (bool): If the dataset does not already exist, whether it
|
||||
should be created as a private dataset or public. Private datasets
|
||||
may require paid huggingface.co accounts
|
||||
verbose (bool): Whether to print out the status of the dataset
|
||||
creation.
|
||||
Parameters:
|
||||
hf_token: The token to use to access the huggingface API.
|
||||
dataset_name: The name of the dataset to save the data to, e.g. "image-classifier-1"
|
||||
organization: The name of the organization to which to attach the datasets. If None, the dataset attaches to the user only.
|
||||
private: If the dataset does not already exist, whether it should be created as a private dataset or public. Private datasets may require paid huggingface.co accounts
|
||||
verbose: Whether to print out the status of the dataset creation.
|
||||
"""
|
||||
self.hf_token = hf_token
|
||||
self.dataset_name = dataset_name
|
||||
|
Loading…
Reference in New Issue
Block a user