Download run.py from aiflows/HumanStandardInputFlowModule: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/aiflows/HumanStandardInputFlowModule/resolve/5683a922372c5fa90be9f6447d6662d8d80341fc/run.py
- Command line
-
hf download hf://aiflows/HumanStandardInputFlowModule@5683a922372c5fa90be9f6447d6662d8d80341fc/run.py
-
curl -L -o run.py https://huggingface.co/aiflows/HumanStandardInputFlowModule/resolve/5683a922372c5fa90be9f6447d6662d8d80341fc/run.py
1.72 kB
| import os | |
| import hydra | |
| from flows.flow_launchers import FlowLauncher | |
| from flows.utils.general_helpers import read_yaml_file | |
| from flows import logging | |
| from flows.flow_cache import CACHING_PARAMETERS | |
| CACHING_PARAMETERS.do_caching = False # Set to True to enable caching | |
| # clear_cache() # Uncomment this line to clear the cache | |
| logging.set_verbosity_debug() | |
| dependencies = [ | |
| {"url": "aiflows/HumanStandardInputFlowModule", "revision": os.getcwd()}, | |
| ] | |
| from flows import flow_verse | |
| flow_verse.sync_dependencies(dependencies) | |
| if __name__ == "__main__": | |
| root_dir = "." | |
| cfg_path = os.path.join(root_dir, "demo.yaml") | |
| cfg = read_yaml_file(cfg_path) | |
| flow_with_interfaces = { | |
| "flow": hydra.utils.instantiate(cfg['flow'], _recursive_=False, _convert_="partial"), | |
| "input_interface": ( | |
| None | |
| if getattr(cfg, "input_interface", None) is None | |
| else hydra.utils.instantiate(cfg['input_interface'], _recursive_=False) | |
| ), | |
| "output_interface": ( | |
| None | |
| if getattr(cfg, "output_interface", None) is None | |
| else hydra.utils.instantiate(cfg['output_interface'], _recursive_=False) | |
| ), | |
| } | |
| # ~~~ Get the data ~~~ | |
| # This can be a list of samples | |
| data = {"id": 0} # Add your data here | |
| # ~~~ Run inference ~~~ | |
| path_to_output_file = None | |
| # path_to_output_file = "output.jsonl" # Uncomment this line to save the output to disk | |
| _, outputs = FlowLauncher.launch( | |
| flow_with_interfaces=flow_with_interfaces, | |
| data=data, | |
| path_to_output_file=path_to_output_file, | |
| ) | |
| # ~~~ Print the output ~~~ | |
| flow_output_data = outputs[0] | |
| print(flow_output_data) | |