yeq6x commited on
Commit
cd3a25e
·
1 Parent(s): 17d3218

Update app.py and README.md to enhance environment variable configuration for model and LoRA settings, improving customization options.

Browse files
Files changed (2) hide show
  1. README.md +7 -2
  2. app.py +7 -6
README.md CHANGED
@@ -37,15 +37,20 @@ Built on [Qwen-Image-Edit-2511](https://huggingface.co/Qwen/Qwen-Image-Edit-2511
37
 
38
  The application uses environment variables for customization:
39
 
 
 
 
40
  ### LoRA Settings
 
 
41
  - `STAGE1_LORA_REPO`: Repository for Stage 1 LoRA (anime → base body)
42
  - `STAGE1_LORA_WEIGHT`: Weight filename for Stage 1 LoRA
43
  - `STAGE2_LORA_REPO`: Repository for Stage 2 LoRA (base body → guide body)
44
  - `STAGE2_LORA_WEIGHT`: Weight filename for Stage 2 LoRA
45
 
46
  ### Prompt Settings
47
- - `STAGE1_PROMPT`: Prompt for Stage 1 conversion
48
- - `STAGE2_PROMPT`: Prompt for Stage 2 conversion
49
 
50
  ## Usage
51
 
 
37
 
38
  The application uses environment variables for customization:
39
 
40
+ ### Model Settings
41
+ - `BASE_MODEL`: Base model repository (default: `Qwen/Qwen-Image-Edit-2511`)
42
+
43
  ### LoRA Settings
44
+ - `LIGHTNING_LORA_REPO`: Lightning 4-step LoRA repository (default: `lightx2v/Qwen-Image-Edit-2511-Lightning`)
45
+ - `LIGHTNING_LORA_WEIGHT`: Lightning LoRA weight filename (default: `Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors`)
46
  - `STAGE1_LORA_REPO`: Repository for Stage 1 LoRA (anime → base body)
47
  - `STAGE1_LORA_WEIGHT`: Weight filename for Stage 1 LoRA
48
  - `STAGE2_LORA_REPO`: Repository for Stage 2 LoRA (base body → guide body)
49
  - `STAGE2_LORA_WEIGHT`: Weight filename for Stage 2 LoRA
50
 
51
  ### Prompt Settings
52
+ - `STAGE1_PROMPT`: Prompt for Stage 1 conversion (default: "Convert anime character to base body structure")
53
+ - `STAGE2_PROMPT`: Prompt for Stage 2 conversion (default: "Convert base body to clear guide body with structure lines")
54
 
55
  ## Usage
56
 
app.py CHANGED
@@ -14,7 +14,10 @@ from diffusers import FlowMatchEulerDiscreteScheduler, QwenImageEditPlusPipeline
14
  import math
15
  import os
16
 
17
- # --- Environment Variables for LoRA and Prompts ---
 
 
 
18
  STAGE1_LORA_REPO = os.environ.get("STAGE1_LORA_REPO", "default/stage1-lora")
19
  STAGE1_LORA_WEIGHT = os.environ.get("STAGE1_LORA_WEIGHT", "stage1.safetensors")
20
  STAGE2_LORA_REPO = os.environ.get("STAGE2_LORA_REPO", "default/stage2-lora")
@@ -48,14 +51,14 @@ scheduler_config = {
48
  scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
49
 
50
  # Load single shared pipeline
51
- pipe = QwenImageEditPlusPipeline.from_pretrained("Qwen/Qwen-Image-Edit-2511",
52
  scheduler=scheduler,
53
  torch_dtype=dtype).to(device)
54
  # Load all LoRAs but don't fuse yet
55
  # Load 4-step Lightning LoRA
56
  pipe.load_lora_weights(
57
- "lightx2v/Qwen-Image-Edit-2511-Lightning",
58
- weight_name="Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors",
59
  adapter_name="lightning"
60
  )
61
  # Load Stage 1 LoRA
@@ -195,8 +198,6 @@ with gr.Blocks(css=css) as demo:
195
  </div>
196
  """)
197
  gr.Markdown("""
198
- Two-stage conversion pipeline powered by [Qwen-Image-Edit-2511](https://huggingface.co/Qwen/Qwen-Image-Edit-2511) with custom LoRAs.
199
-
200
  **Stage 1:** Converts anime characters to base body structure
201
  **Stage 2:** Converts base body to clear guide body with structure lines
202
  """)
 
14
  import math
15
  import os
16
 
17
+ # --- Environment Variables for Model, LoRA and Prompts ---
18
+ BASE_MODEL = os.environ.get("BASE_MODEL", "Qwen/Qwen-Image-Edit-2511")
19
+ LIGHTNING_LORA_REPO = os.environ.get("LIGHTNING_LORA_REPO", "lightx2v/Qwen-Image-Edit-2511-Lightning")
20
+ LIGHTNING_LORA_WEIGHT = os.environ.get("LIGHTNING_LORA_WEIGHT", "Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors")
21
  STAGE1_LORA_REPO = os.environ.get("STAGE1_LORA_REPO", "default/stage1-lora")
22
  STAGE1_LORA_WEIGHT = os.environ.get("STAGE1_LORA_WEIGHT", "stage1.safetensors")
23
  STAGE2_LORA_REPO = os.environ.get("STAGE2_LORA_REPO", "default/stage2-lora")
 
51
  scheduler = FlowMatchEulerDiscreteScheduler.from_config(scheduler_config)
52
 
53
  # Load single shared pipeline
54
+ pipe = QwenImageEditPlusPipeline.from_pretrained(BASE_MODEL,
55
  scheduler=scheduler,
56
  torch_dtype=dtype).to(device)
57
  # Load all LoRAs but don't fuse yet
58
  # Load 4-step Lightning LoRA
59
  pipe.load_lora_weights(
60
+ LIGHTNING_LORA_REPO,
61
+ weight_name=LIGHTNING_LORA_WEIGHT,
62
  adapter_name="lightning"
63
  )
64
  # Load Stage 1 LoRA
 
198
  </div>
199
  """)
200
  gr.Markdown("""
 
 
201
  **Stage 1:** Converts anime characters to base body structure
202
  **Stage 2:** Converts base body to clear guide body with structure lines
203
  """)