ariG23498 HF Staff commited on
Commit
25fc3d8
·
verified ·
1 Parent(s): ad2e4b8

Upload black-forest-labs_FLUX.1-Krea-dev_3.py with huggingface_hub

Browse files
black-forest-labs_FLUX.1-Krea-dev_3.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "transformers",
5
+ # "torch",
6
+ # ]
7
+ # ///
8
+
9
+ try:
10
+ import os
11
+ from huggingface_hub import InferenceClient
12
+
13
+ client = InferenceClient(
14
+ provider="auto",
15
+ api_key=os.environ["HF_TOKEN"],
16
+ )
17
+
18
+ # output is a PIL.Image object
19
+ image = client.text_to_image(
20
+ "Astronaut riding a horse",
21
+ model="black-forest-labs/FLUX.1-Krea-dev",
22
+ )
23
+ with open('black-forest-labs_FLUX.1-Krea-dev_3.txt', 'w') as f:
24
+ f.write('Everything was good in black-forest-labs_FLUX.1-Krea-dev_3.txt')
25
+ except Exception as e:
26
+ with open('black-forest-labs_FLUX.1-Krea-dev_3.txt', 'w') as f:
27
+ import traceback
28
+ traceback.print_exc(file=f)
29
+ finally:
30
+ from huggingface_hub import upload_file
31
+ upload_file(
32
+ path_or_fileobj='black-forest-labs_FLUX.1-Krea-dev_3.txt',
33
+ repo_id='model-metadata/custom_code_execution_files',
34
+ path_in_repo='black-forest-labs_FLUX.1-Krea-dev_3.txt',
35
+ repo_type='dataset',
36
+ )