ariG23498 HF Staff commited on
Commit
c60d91f
·
verified ·
1 Parent(s): 98bb254

Upload Shakker-Labs_AWPortrait-Z_0.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. Shakker-Labs_AWPortrait-Z_0.py +68 -0
Shakker-Labs_AWPortrait-Z_0.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "numpy",
5
+ # "einops",
6
+ # "pandas",
7
+ # "matplotlib",
8
+ # "protobuf",
9
+ # "torch",
10
+ # "sentencepiece",
11
+ # "torchvision",
12
+ # "transformers",
13
+ # "timm",
14
+ # "diffusers",
15
+ # "sentence-transformers",
16
+ # "accelerate",
17
+ # "peft",
18
+ # "slack-sdk",
19
+ # ]
20
+ # ///
21
+
22
+ try:
23
+ import torch
24
+ from diffusers import DiffusionPipeline
25
+
26
+ # switch to "mps" for apple devices
27
+ pipe = DiffusionPipeline.from_pretrained("Tongyi-MAI/Z-Image-Turbo", dtype=torch.bfloat16, device_map="cuda")
28
+ pipe.load_lora_weights("Shakker-Labs/AWPortrait-Z")
29
+
30
+ prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
31
+ image = pipe(prompt).images[0]
32
+ with open('Shakker-Labs_AWPortrait-Z_0.txt', 'w', encoding='utf-8') as f:
33
+ f.write('Everything was good in Shakker-Labs_AWPortrait-Z_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/Shakker-Labs_AWPortrait-Z_0.txt|Shakker-Labs_AWPortrait-Z_0.txt>',
41
+ )
42
+
43
+ with open('Shakker-Labs_AWPortrait-Z_0.txt', 'a', encoding='utf-8') as f:
44
+ import traceback
45
+ f.write('''```CODE:
46
+ import torch
47
+ from diffusers import DiffusionPipeline
48
+
49
+ # switch to "mps" for apple devices
50
+ pipe = DiffusionPipeline.from_pretrained("Tongyi-MAI/Z-Image-Turbo", dtype=torch.bfloat16, device_map="cuda")
51
+ pipe.load_lora_weights("Shakker-Labs/AWPortrait-Z")
52
+
53
+ prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
54
+ image = pipe(prompt).images[0]
55
+ ```
56
+
57
+ ERROR:
58
+ ''')
59
+ traceback.print_exc(file=f)
60
+
61
+ finally:
62
+ from huggingface_hub import upload_file
63
+ upload_file(
64
+ path_or_fileobj='Shakker-Labs_AWPortrait-Z_0.txt',
65
+ repo_id='model-metadata/code_execution_files',
66
+ path_in_repo='Shakker-Labs_AWPortrait-Z_0.txt',
67
+ repo_type='dataset',
68
+ )