CoolFace
Datasetpublic

model-metadata/code_python_files

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes13kdownloads
black-forest-labs_FLUX.1-dev_4.py68 linesDownload Raw Back to root
1# /// script2# requires-python = ">=3.12"3# dependencies = [4#     "torch",5#     "torchvision",6#     "transformers",7#     "accelerate",8#     "peft",9#     "slack-sdk",10# ]11# ///12 13try:14    import os15    from huggingface_hub import InferenceClient16    17    client = InferenceClient(18        provider="auto",19        api_key=os.environ["HF_TOKEN"],20    )21    22    # output is a PIL.Image object23    image = client.text_to_image(24        "Astronaut riding a horse",25        model="black-forest-labs/FLUX.1-dev",26    )27    with open('black-forest-labs_FLUX.1-dev_4.txt', 'w', encoding='utf-8') as f:28        f.write('Everything was good in black-forest-labs_FLUX.1-dev_4.txt')29except Exception as e:30    import os31    from slack_sdk import WebClient32    client = WebClient(token=os.environ['SLACK_TOKEN'])33    client.chat_postMessage(34        channel='#exp-slack-alerts',35        text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/black-forest-labs_FLUX.1-dev_4.txt|black-forest-labs_FLUX.1-dev_4.txt>',36    )37 38    with open('black-forest-labs_FLUX.1-dev_4.txt', 'a', encoding='utf-8') as f:39        import traceback40        f.write('''```CODE: 41import os42from huggingface_hub import InferenceClient43 44client = InferenceClient(45    provider="auto",46    api_key=os.environ["HF_TOKEN"],47)48 49# output is a PIL.Image object50image = client.text_to_image(51    "Astronaut riding a horse",52    model="black-forest-labs/FLUX.1-dev",53)54```55 56ERROR: 57''')58        traceback.print_exc(file=f)59    60finally:61    from huggingface_hub import upload_file62    upload_file(63        path_or_fileobj='black-forest-labs_FLUX.1-dev_4.txt',64        repo_id='model-metadata/code_execution_files',65        path_in_repo='black-forest-labs_FLUX.1-dev_4.txt',66        repo_type='dataset',67    )68