Spaces:
Sleeping
Sleeping
Anurag181011
commited on
Commit
·
f9d1adb
1
Parent(s):
cdbd072
ifofk
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ LORA_REPO_ID = "strangerzonehf/Flux-Ghibli-Art-LoRA"
|
|
12 |
TRIGGER_WORD = "Ghibli Art"
|
13 |
STRENGTH = 0.60 # Adjust for better balance between input and style
|
14 |
GUIDANCE_SCALE = 7.5 # Increased for better prompt adherence
|
15 |
-
|
16 |
INPUT_IMAGE_SIZE = (512, 512)
|
17 |
PROMPT_PREFIX = "" # No need for separate prefix as LoRA is targeted
|
18 |
NEGATIVE_PROMPT = "ugly, deformed, blurry, low quality, bad anatomy, bad proportions, disfigured, poorly drawn face, mutation, mutated, extra limbs, extra fingers, body horror, glitchy, tiling"
|
@@ -43,7 +43,8 @@ try:
|
|
43 |
pipe.load_lora_weights(LORA_REPO_ID)
|
44 |
print(f"✅ LoRA weights loaded from {LORA_REPO_ID}")
|
45 |
except Exception as e:
|
46 |
-
print(f"⚠️ Error loading LoRA weights:
|
|
|
47 |
|
48 |
pipe.to(device)
|
49 |
|
@@ -68,12 +69,17 @@ def transform_image(input_image):
|
|
68 |
|
69 |
prompt = f"{PROMPT_PREFIX} {TRIGGER_WORD}, portrait of a person" # Incorporate trigger word
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
output = pipe(
|
72 |
prompt=prompt,
|
73 |
-
image=input_image,
|
74 |
-
strength=STRENGTH,
|
75 |
guidance_scale=GUIDANCE_SCALE,
|
76 |
-
num_inference_steps=
|
77 |
negative_prompt=NEGATIVE_PROMPT,
|
78 |
).images[0]
|
79 |
|
|
|
12 |
TRIGGER_WORD = "Ghibli Art"
|
13 |
STRENGTH = 0.60 # Adjust for better balance between input and style
|
14 |
GUIDANCE_SCALE = 7.5 # Increased for better prompt adherence
|
15 |
+
NUM_inference_steps = 30 # Increased for potentially higher quality
|
16 |
INPUT_IMAGE_SIZE = (512, 512)
|
17 |
PROMPT_PREFIX = "" # No need for separate prefix as LoRA is targeted
|
18 |
NEGATIVE_PROMPT = "ugly, deformed, blurry, low quality, bad anatomy, bad proportions, disfigured, poorly drawn face, mutation, mutated, extra limbs, extra fingers, body horror, glitchy, tiling"
|
|
|
43 |
pipe.load_lora_weights(LORA_REPO_ID)
|
44 |
print(f"✅ LoRA weights loaded from {LORA_REPO_ID}")
|
45 |
except Exception as e:
|
46 |
+
print(f"⚠️ Error loading LoRA weights: PEFT backend is required. Please install it with: pip install peft")
|
47 |
+
print("⚠️ Continuing without LoRA, results may vary.")
|
48 |
|
49 |
pipe.to(device)
|
50 |
|
|
|
69 |
|
70 |
prompt = f"{PROMPT_PREFIX} {TRIGGER_WORD}, portrait of a person" # Incorporate trigger word
|
71 |
|
72 |
+
# FLUX.1-dev does not seem to directly support the 'image' argument for image-to-image.
|
73 |
+
# We will try to influence the generation using the prompt, describing the input image.
|
74 |
+
# This is a workaround as direct image-to-image is not available with this pipeline.
|
75 |
+
|
76 |
+
# Basic description of the input image (you can make this more detailed)
|
77 |
+
prompt += f", photo of a person"
|
78 |
+
|
79 |
output = pipe(
|
80 |
prompt=prompt,
|
|
|
|
|
81 |
guidance_scale=GUIDANCE_SCALE,
|
82 |
+
num_inference_steps=NUM_inference_steps,
|
83 |
negative_prompt=NEGATIVE_PROMPT,
|
84 |
).images[0]
|
85 |
|