ariG23498 HF Staff commited on
Commit
5ee4322
·
verified ·
1 Parent(s): fac8bb9

Upload ilkerzgi_Overlay-Kontext-Dev-LoRA_0.py with huggingface_hub

Browse files
ilkerzgi_Overlay-Kontext-Dev-LoRA_0.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # requires-python = ">=3.12"
3
+ # dependencies = [
4
+ # "numpy",
5
+ # "einops",
6
+ # "torch",
7
+ # "transformers",
8
+ # "datasets",
9
+ # "accelerate",
10
+ # "timm",
11
+ # ]
12
+ # ///
13
+
14
+ try:
15
+ from diffusers import DiffusionPipeline
16
+ from diffusers.utils import load_image
17
+
18
+ pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-Kontext-dev")
19
+ pipe.load_lora_weights("ilkerzgi/Overlay-Kontext-Dev-LoRA")
20
+
21
+ prompt = "Place it"
22
+ input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png")
23
+
24
+ image = pipe(image=input_image, prompt=prompt).images[0]
25
+ with open('ilkerzgi_Overlay-Kontext-Dev-LoRA_0.txt', 'w') as f:
26
+ f.write('Everything was good in ilkerzgi_Overlay-Kontext-Dev-LoRA_0.txt')
27
+ except Exception as e:
28
+ with open('ilkerzgi_Overlay-Kontext-Dev-LoRA_0.txt', 'w') as f:
29
+ import traceback
30
+ traceback.print_exc(file=f)
31
+ finally:
32
+ from huggingface_hub import upload_file
33
+ upload_file(
34
+ path_or_fileobj='ilkerzgi_Overlay-Kontext-Dev-LoRA_0.txt',
35
+ repo_id='model-metadata/custom_code_execution_files',
36
+ path_in_repo='ilkerzgi_Overlay-Kontext-Dev-LoRA_0.txt',
37
+ repo_type='dataset',
38
+ )