ariG23498 HF Staff commited on
Commit
64594f4
·
verified ·
1 Parent(s): 4312796

Upload dx8152_Qwen-Image-Edit-2509-Relight_0.py with huggingface_hub

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