Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,9 +42,9 @@ class ImageProcessor:
|
|
| 42 |
return image
|
| 43 |
|
| 44 |
# Initialize the image processor
|
| 45 |
-
base_path = "
|
| 46 |
-
lora_base_path = "
|
| 47 |
-
style_lora_base_path = "
|
| 48 |
processor = ImageProcessor(base_path)
|
| 49 |
|
| 50 |
# Define the Gradio interface
|
|
@@ -72,16 +72,16 @@ def single_condition_generate_image(prompt, subject_img, spatial_img, height, wi
|
|
| 72 |
else:
|
| 73 |
if style_lora == "Simple_Sketch":
|
| 74 |
processor.pipe.unload_lora_weights()
|
| 75 |
-
style_lora_path = os.path.join(style_lora_base_path, "FLUX.1-dev-LoRA-Children-Simple-Sketch
|
| 76 |
-
processor.pipe.load_lora_weights(
|
| 77 |
if style_lora == "Text_Poster":
|
| 78 |
processor.pipe.unload_lora_weights()
|
| 79 |
-
style_lora_path = os.path.join(style_lora_base_path, "FLUX.1-dev-LoRA-Text-Poster
|
| 80 |
-
processor.pipe.load_lora_weights(
|
| 81 |
if style_lora == "Vector_Style":
|
| 82 |
processor.pipe.unload_lora_weights()
|
| 83 |
-
style_lora_path = os.path.join(style_lora_base_path, "FLUX.1-dev-LoRA-Vector-Journey
|
| 84 |
-
processor.pipe.load_lora_weights(style_lora_path, weight_name="
|
| 85 |
|
| 86 |
# Process the image
|
| 87 |
subject_imgs = [subject_img] if subject_img else []
|
|
@@ -107,11 +107,11 @@ style_loras = ["Simple_Sketch", "Text_Poster", "Vector_Style", "None"]
|
|
| 107 |
|
| 108 |
# Example data
|
| 109 |
single_examples = [
|
| 110 |
-
["A SKS in the library", Image.open("
|
| 111 |
-
["In a picturesque village, a narrow cobblestone street with rustic stone buildings, colorful blinds, and lush green spaces, a cartoon man drawn with simple lines and solid colors stands in the foreground, wearing a red shirt, beige work pants, and brown shoes, carrying a strap on his shoulder. The scene features warm and enticing colors, a pleasant fusion of nature and architecture, and the camera's perspective on the street clearly shows the charming and quaint environment., Integrating elements of reality and cartoon.", None, Image.open("
|
| 112 |
]
|
| 113 |
multi_examples = [
|
| 114 |
-
["A SKS on the car", Image.open("
|
| 115 |
]
|
| 116 |
|
| 117 |
|
|
@@ -141,7 +141,7 @@ with gr.Blocks() as demo:
|
|
| 141 |
inputs=[prompt, subject_img, spatial_img, height, width, seed, control_type, style_lora],
|
| 142 |
outputs=single_output_image,
|
| 143 |
fn=single_condition_generate_image,
|
| 144 |
-
cache_examples=
|
| 145 |
label="Single Condition Examples"
|
| 146 |
)
|
| 147 |
|
|
@@ -165,7 +165,7 @@ with gr.Blocks() as demo:
|
|
| 165 |
inputs=[multi_prompt, multi_subject_img, multi_spatial_img, multi_height, multi_width, multi_seed],
|
| 166 |
outputs=multi_output_image,
|
| 167 |
fn=multi_condition_generate_image,
|
| 168 |
-
cache_examples=
|
| 169 |
label="Multi-Condition Examples"
|
| 170 |
)
|
| 171 |
|
|
@@ -183,4 +183,4 @@ with gr.Blocks() as demo:
|
|
| 183 |
)
|
| 184 |
|
| 185 |
# Launch the Gradio app
|
| 186 |
-
demo.queue().launch(
|
|
|
|
| 42 |
return image
|
| 43 |
|
| 44 |
# Initialize the image processor
|
| 45 |
+
base_path = "black-forest-labs/FLUX.1-dev"
|
| 46 |
+
lora_base_path = "EasyControl/models"
|
| 47 |
+
style_lora_base_path = "Shakker-Labs"
|
| 48 |
processor = ImageProcessor(base_path)
|
| 49 |
|
| 50 |
# Define the Gradio interface
|
|
|
|
| 72 |
else:
|
| 73 |
if style_lora == "Simple_Sketch":
|
| 74 |
processor.pipe.unload_lora_weights()
|
| 75 |
+
style_lora_path = os.path.join(style_lora_base_path, "FLUX.1-dev-LoRA-Children-Simple-Sketch")
|
| 76 |
+
processor.pipe.load_lora_weights(style_lora_path, weight_name="FLUX-dev-lora-children-simple-sketch.safetensors")
|
| 77 |
if style_lora == "Text_Poster":
|
| 78 |
processor.pipe.unload_lora_weights()
|
| 79 |
+
style_lora_path = os.path.join(style_lora_base_path, "FLUX.1-dev-LoRA-Text-Poster")
|
| 80 |
+
processor.pipe.load_lora_weights(style_lora_path, weight_name="FLUX-dev-lora-Text-Poster.safetensors")
|
| 81 |
if style_lora == "Vector_Style":
|
| 82 |
processor.pipe.unload_lora_weights()
|
| 83 |
+
style_lora_path = os.path.join(style_lora_base_path, "FLUX.1-dev-LoRA-Vector-Journey")
|
| 84 |
+
processor.pipe.load_lora_weights(style_lora_path, weight_name="FLUX-dev-lora-Vector-Journey.safetensors")
|
| 85 |
|
| 86 |
# Process the image
|
| 87 |
subject_imgs = [subject_img] if subject_img else []
|
|
|
|
| 107 |
|
| 108 |
# Example data
|
| 109 |
single_examples = [
|
| 110 |
+
["A SKS in the library", Image.open("./test_imgs/subject1.jpg"), None, 1024, 1024, 5, "subject", None],
|
| 111 |
+
["In a picturesque village, a narrow cobblestone street with rustic stone buildings, colorful blinds, and lush green spaces, a cartoon man drawn with simple lines and solid colors stands in the foreground, wearing a red shirt, beige work pants, and brown shoes, carrying a strap on his shoulder. The scene features warm and enticing colors, a pleasant fusion of nature and architecture, and the camera's perspective on the street clearly shows the charming and quaint environment., Integrating elements of reality and cartoon.", None, Image.open("./test_imgs/openpose.png"), 1024, 1024, 1, "pose", "Vector_Style"],
|
| 112 |
]
|
| 113 |
multi_examples = [
|
| 114 |
+
["A SKS on the car", Image.open("./test_imgs/subject2.png"), Image.open("./test_imgs/inpainting.png"), 1024, 1024, 7],
|
| 115 |
]
|
| 116 |
|
| 117 |
|
|
|
|
| 141 |
inputs=[prompt, subject_img, spatial_img, height, width, seed, control_type, style_lora],
|
| 142 |
outputs=single_output_image,
|
| 143 |
fn=single_condition_generate_image,
|
| 144 |
+
cache_examples=False, # ηΌεη€ΊδΎη»ζδ»₯ε εΏ«ε θ½½ιεΊ¦
|
| 145 |
label="Single Condition Examples"
|
| 146 |
)
|
| 147 |
|
|
|
|
| 165 |
inputs=[multi_prompt, multi_subject_img, multi_spatial_img, multi_height, multi_width, multi_seed],
|
| 166 |
outputs=multi_output_image,
|
| 167 |
fn=multi_condition_generate_image,
|
| 168 |
+
cache_examples=False, # ηΌεη€ΊδΎη»ζδ»₯ε εΏ«ε θ½½ιεΊ¦
|
| 169 |
label="Multi-Condition Examples"
|
| 170 |
)
|
| 171 |
|
|
|
|
| 183 |
)
|
| 184 |
|
| 185 |
# Launch the Gradio app
|
| 186 |
+
demo.queue().launch()
|