TuringsSolutions commited on
Commit
6cd8c22
·
verified ·
1 Parent(s): 4c37d59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -20
app.py CHANGED
@@ -1,6 +1,11 @@
1
  import gradio as gr
2
  import torch
3
- from diffusers import StableDiffusionXLPipeline, EulerDiscreteScheduler
 
 
 
 
 
4
  from huggingface_hub import hf_hub_download
5
 
6
  # --- Configuration ---
@@ -36,14 +41,14 @@ pipe.load_lora_weights(lora_file_path)
36
  pipe.to("cuda")
37
 
38
  # --- Default Settings from your Recommendations ---
39
- # These are pulled directly from your "Recomendations.txt".
40
- default_positive_prompt = "masterpiece, best quality, ultra-detailed, realistic skin, intricate details, highres" #
41
- default_negative_prompt = "low quality, worst quality, blurry, (deformed:1.3), extra fingers, cartoon, 3d, anime, bad anatomy" #
42
- default_sampler = "DPM++ 2M Karras" #
43
- default_cfg = 6.0 #
44
- default_steps = 30 #
45
- trigger_word = "emilyh" #
46
- lora_tag_main = "<lora:emilyh:0.9>" #
47
 
48
 
49
  # --- Define the Inference Function ---
@@ -51,7 +56,7 @@ def generate_image(prompt, negative_prompt, sampler, steps, cfg, width, height,
51
  """
52
  Function to generate an image based on user inputs.
53
  """
54
- # Combine the user prompt with the trigger word and LoRA tag
55
  full_prompt = f"{lora_tag_main}, {trigger_word}, {prompt}"
56
 
57
  # Set the scheduler (sampler)
@@ -84,7 +89,7 @@ with gr.Blocks(css="style.css") as demo:
84
  gr.Markdown("# `emilyh` LoRA Image Generator")
85
  gr.Markdown(
86
  "A Gradio interface for the `emilyh` LoRA. "
87
- "Based on the recommendations provided. "
88
  )
89
 
90
  with gr.Row():
@@ -97,10 +102,10 @@ with gr.Blocks(css="style.css") as demo:
97
  label="Sampler",
98
  choices=["DPM++ 2M Karras", "DPM++ SDE Karras"],
99
  value=default_sampler,
100
- ) #
101
- steps = gr.Slider(label="Steps", minimum=15, maximum=50, value=default_steps, step=1) #
102
 
103
- cfg = gr.Slider(label="CFG Scale", minimum=1.0, maximum=10.0, value=default_cfg, step=0.5) #
104
 
105
  with gr.Row():
106
  width = gr.Slider(label="Width", minimum=512, maximum=1024, value=1024, step=64)
@@ -114,12 +119,12 @@ with gr.Blocks(css="style.css") as demo:
114
  output_image = gr.Image(label="Generated Image", type="pil")
115
  gr.Markdown(
116
  """
117
- ### 🔧 Usage Guide
118
- * The trigger word `emilyh` and the LoRA tag `<lora:emilyh:0.9>` are automatically added to your prompt.
119
- * For best results, generate images in batches and choose the most consistent ones.
120
- * The LoRA captures the subject's appearance well across various poses and outfits.
121
- * A weight of 0.9 provides a good balance of likeness and flexibility. Using a weight closer to 1.0 can increase consistency but may cause stiffness.
122
- * This interface does not include ADetailer, which is recommended for final face refinement.
123
  """
124
  )
125
 
 
1
  import gradio as gr
2
  import torch
3
+ from diffusers import (
4
+ StableDiffusionXLPipeline,
5
+ EulerDiscreteScheduler,
6
+ AutoencoderKL,
7
+ DPMSolverSinglestepScheduler,
8
+ )
9
  from huggingface_hub import hf_hub_download
10
 
11
  # --- Configuration ---
 
41
  pipe.to("cuda")
42
 
43
  # --- Default Settings from your Recommendations ---
44
+ # These are pulled directly from your "Recomendations.txt".
45
+ default_positive_prompt = "masterpiece, best quality, ultra-detailed, realistic skin, intricate details, highres"
46
+ default_negative_prompt = "low quality, worst quality, blurry, (deformed:1.3), extra fingers, cartoon, 3d, anime, bad anatomy"
47
+ default_sampler = "DPM++ 2M Karras"
48
+ default_cfg = 6.0
49
+ default_steps = 30
50
+ trigger_word = "emilyh"
51
+ lora_tag_main = "<lora:emilyh:0.9>"
52
 
53
 
54
  # --- Define the Inference Function ---
 
56
  """
57
  Function to generate an image based on user inputs.
58
  """
59
+ # Combine the user prompt with the trigger word and LoRA tag
60
  full_prompt = f"{lora_tag_main}, {trigger_word}, {prompt}"
61
 
62
  # Set the scheduler (sampler)
 
89
  gr.Markdown("# `emilyh` LoRA Image Generator")
90
  gr.Markdown(
91
  "A Gradio interface for the `emilyh` LoRA. "
92
+ "Based on the recommendations provided."
93
  )
94
 
95
  with gr.Row():
 
102
  label="Sampler",
103
  choices=["DPM++ 2M Karras", "DPM++ SDE Karras"],
104
  value=default_sampler,
105
+ )
106
+ steps = gr.Slider(label="Steps", minimum=15, maximum=50, value=default_steps, step=1)
107
 
108
+ cfg = gr.Slider(label="CFG Scale", minimum=1.0, maximum=10.0, value=default_cfg, step=0.5)
109
 
110
  with gr.Row():
111
  width = gr.Slider(label="Width", minimum=512, maximum=1024, value=1024, step=64)
 
119
  output_image = gr.Image(label="Generated Image", type="pil")
120
  gr.Markdown(
121
  """
122
+ ### 🔧 Usage Guide
123
+ * The trigger word `emilyh` and the LoRA tag `<lora:emilyh:0.9>` are automatically added to your prompt.
124
+ * For best results, generate images in batches and choose the most consistent ones.
125
+ * The LoRA captures the subject's appearance well across various poses and outfits.
126
+ * A weight of 0.9 provides a good balance of likeness and flexibility. Using a weight closer to 1.0 can increase consistency but may cause stiffness.
127
+ * This interface does not include ADetailer, which is recommended for final face refinement.
128
  """
129
  )
130