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