Upload lovis93_next-scene-qwen-image-lora-2509_1.py with huggingface_hub
Browse files
    	
        lovis93_next-scene-qwen-image-lora-2509_1.py
    ADDED
    
    | @@ -0,0 +1,61 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            # /// script
         | 
| 2 | 
            +
            # requires-python = ">=3.12"
         | 
| 3 | 
            +
            # dependencies = [
         | 
| 4 | 
            +
            #     "torch",
         | 
| 5 | 
            +
            #     "torchvision",
         | 
| 6 | 
            +
            #     "transformers",
         | 
| 7 | 
            +
            #     "accelerate",
         | 
| 8 | 
            +
            #     "peft",
         | 
| 9 | 
            +
            #     "slack-sdk",
         | 
| 10 | 
            +
            # ]
         | 
| 11 | 
            +
            # ///
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            try:
         | 
| 14 | 
            +
                from diffusers import DiffusionPipeline
         | 
| 15 | 
            +
                from diffusers.utils import load_image
         | 
| 16 | 
            +
                
         | 
| 17 | 
            +
                pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509")
         | 
| 18 | 
            +
                pipe.load_lora_weights("lovis93/next-scene-qwen-image-lora-2509")
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                prompt = "Turn this cat into a dog"
         | 
| 21 | 
            +
                input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")
         | 
| 22 | 
            +
                
         | 
| 23 | 
            +
                image = pipe(image=input_image, prompt=prompt).images[0]
         | 
| 24 | 
            +
                with open('lovis93_next-scene-qwen-image-lora-2509_1.txt', 'w', encoding='utf-8') as f:
         | 
| 25 | 
            +
                    f.write('Everything was good in lovis93_next-scene-qwen-image-lora-2509_1.txt')
         | 
| 26 | 
            +
            except Exception as e:
         | 
| 27 | 
            +
                import os
         | 
| 28 | 
            +
                from slack_sdk import WebClient
         | 
| 29 | 
            +
                client = WebClient(token=os.environ['SLACK_TOKEN'])
         | 
| 30 | 
            +
                client.chat_postMessage(
         | 
| 31 | 
            +
                    channel='#exp-slack-alerts',
         | 
| 32 | 
            +
                    text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/lovis93_next-scene-qwen-image-lora-2509_1.txt|lovis93_next-scene-qwen-image-lora-2509_1.txt>',
         | 
| 33 | 
            +
                )
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                with open('lovis93_next-scene-qwen-image-lora-2509_1.txt', 'a', encoding='utf-8') as f:
         | 
| 36 | 
            +
                    import traceback
         | 
| 37 | 
            +
                    f.write('''```CODE: 
         | 
| 38 | 
            +
            from diffusers import DiffusionPipeline
         | 
| 39 | 
            +
            from diffusers.utils import load_image
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            pipe = DiffusionPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2509")
         | 
| 42 | 
            +
            pipe.load_lora_weights("lovis93/next-scene-qwen-image-lora-2509")
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            prompt = "Turn this cat into a dog"
         | 
| 45 | 
            +
            input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            image = pipe(image=input_image, prompt=prompt).images[0]
         | 
| 48 | 
            +
            ```
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            ERROR: 
         | 
| 51 | 
            +
            ''')
         | 
| 52 | 
            +
                    traceback.print_exc(file=f)
         | 
| 53 | 
            +
                
         | 
| 54 | 
            +
            finally:
         | 
| 55 | 
            +
                from huggingface_hub import upload_file
         | 
| 56 | 
            +
                upload_file(
         | 
| 57 | 
            +
                    path_or_fileobj='lovis93_next-scene-qwen-image-lora-2509_1.txt',
         | 
| 58 | 
            +
                    repo_id='model-metadata/code_execution_files',
         | 
| 59 | 
            +
                    path_in_repo='lovis93_next-scene-qwen-image-lora-2509_1.txt',
         | 
| 60 | 
            +
                    repo_type='dataset',
         | 
| 61 | 
            +
                )
         | 
