Upload black-forest-labs_FLUX.1-Kontext-dev_1.py with huggingface_hub
Browse files1234567891011121314151617181920212223242526272829303132# /// script# requires-python = ">=3.12"# dependencies = [# "transformers",# "torch",# ]# ///
try: from diffusers import DiffusionPipeline from diffusers.utils import load_image pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] with open('black-forest-labs_FLUX.1-Kontext-dev_1.txt', 'w') as f: f.write('Everything was good in black-forest-labs_FLUX.1-Kontext-dev_1.txt')except Exception as e: with open('black-forest-labs_FLUX.1-Kontext-dev_1.txt', 'w') as f: import traceback traceback.print_exc(file=f)finally: from huggingface_hub import upload_file upload_file( path_or_fileobj='black-forest-labs_FLUX.1-Kontext-dev_1.txt', repo_id='model-metadata/custom_code_execution_files', path_in_repo='black-forest-labs_FLUX.1-Kontext-dev_1.txt', repo_type='dataset', )black-forest-labs_FLUX.1-Kontext-dev_1.pyAdded+32