Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import json
|
|
| 9 |
from huggingface_hub import hf_hub_download, HfApi, create_repo, upload_file
|
| 10 |
import tempfile
|
| 11 |
import multiprocessing as mp
|
|
|
|
| 12 |
|
| 13 |
# Training imports
|
| 14 |
from peft import LoraConfig, get_peft_model
|
|
@@ -640,6 +641,7 @@ Trigger: `{trigger_word}`
|
|
| 640 |
return False, str(e)
|
| 641 |
|
| 642 |
|
|
|
|
| 643 |
def train_lora(
|
| 644 |
images, trigger_word, output_name, num_steps, learning_rate, lora_rank,
|
| 645 |
resolution, batch_size, upload_to_hub_flag, hub_repo_name,
|
|
@@ -1023,7 +1025,7 @@ image = pipe("{trigger_word}, your prompt here", num_inference_steps=8, guidance
|
|
| 1023 |
# ============================================
|
| 1024 |
# Gradio UI with Comic Style
|
| 1025 |
# ============================================
|
| 1026 |
-
with gr.Blocks(
|
| 1027 |
|
| 1028 |
# HOME Button
|
| 1029 |
gr.HTML("""
|
|
@@ -1173,4 +1175,4 @@ with gr.Blocks(css=COMIC_CSS, theme=gr.themes.Soft(), title="Z-IMAGE GEN/LORA")
|
|
| 1173 |
|
| 1174 |
if __name__ == "__main__":
|
| 1175 |
mp.set_start_method('spawn', force=True)
|
| 1176 |
-
demo.launch()
|
|
|
|
| 9 |
from huggingface_hub import hf_hub_download, HfApi, create_repo, upload_file
|
| 10 |
import tempfile
|
| 11 |
import multiprocessing as mp
|
| 12 |
+
import spaces # ZeroGPU support
|
| 13 |
|
| 14 |
# Training imports
|
| 15 |
from peft import LoraConfig, get_peft_model
|
|
|
|
| 641 |
return False, str(e)
|
| 642 |
|
| 643 |
|
| 644 |
+
@spaces.GPU(duration=600) # 10 minutes max for training
|
| 645 |
def train_lora(
|
| 646 |
images, trigger_word, output_name, num_steps, learning_rate, lora_rank,
|
| 647 |
resolution, batch_size, upload_to_hub_flag, hub_repo_name,
|
|
|
|
| 1025 |
# ============================================
|
| 1026 |
# Gradio UI with Comic Style
|
| 1027 |
# ============================================
|
| 1028 |
+
with gr.Blocks(title="Z-IMAGE GEN/LORA") as demo:
|
| 1029 |
|
| 1030 |
# HOME Button
|
| 1031 |
gr.HTML("""
|
|
|
|
| 1175 |
|
| 1176 |
if __name__ == "__main__":
|
| 1177 |
mp.set_start_method('spawn', force=True)
|
| 1178 |
+
demo.launch(css=COMIC_CSS, theme=gr.themes.Soft(), ssr_mode=False)
|