Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import spaces
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
from PIL import Image
|
@@ -10,7 +9,7 @@ import numpy as np
|
|
10 |
|
11 |
def save_image(img):
|
12 |
unique_name = str(uuid.uuid4()) + ".png"
|
13 |
-
img.save(
|
14 |
return unique_name
|
15 |
|
16 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
@@ -84,8 +83,10 @@ def generate(
|
|
84 |
lora_repo = LORA_OPTIONS[lora_choice]["lora_repo"]
|
85 |
trigger_word = LORA_OPTIONS[lora_choice]["trigger_word"]
|
86 |
|
|
|
87 |
pipe.load_lora_weights(lora_repo)
|
88 |
-
pipe.to("cuda")
|
|
|
89 |
|
90 |
if trigger_word:
|
91 |
positive_prompt = f"{trigger_word} {positive_prompt}"
|
@@ -139,12 +140,6 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
139 |
run_button = gr.Button("Generate as : ( 1280 x 832 )π€", scale=0, elem_classes="submit-btn")
|
140 |
|
141 |
with gr.Accordion("Advanced options", open=True, visible=True):
|
142 |
-
model_choice = gr.Dropdown(
|
143 |
-
label="LoRA Selection",
|
144 |
-
choices=list(LORA_OPTIONS.keys()),
|
145 |
-
value="Sketch-Smudge"
|
146 |
-
)
|
147 |
-
|
148 |
seed = gr.Slider(
|
149 |
label="Seed",
|
150 |
minimum=0,
|
@@ -196,7 +191,11 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
196 |
label="Quality Style",
|
197 |
)
|
198 |
|
199 |
-
|
|
|
|
|
|
|
|
|
200 |
|
201 |
with gr.Column(scale=2):
|
202 |
result = gr.Gallery(label="Result", columns=1, show_label=False)
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from PIL import Image
|
|
|
9 |
|
10 |
def save_image(img):
|
11 |
unique_name = str(uuid.uuid4()) + ".png"
|
12 |
+
img.save(unique_name)
|
13 |
return unique_name
|
14 |
|
15 |
def randomize_seed_fn(seed: int, randomize_seed: bool) -> int:
|
|
|
83 |
lora_repo = LORA_OPTIONS[lora_choice]["lora_repo"]
|
84 |
trigger_word = LORA_OPTIONS[lora_choice]["trigger_word"]
|
85 |
|
86 |
+
# Load LoRA weights and move them to GPU
|
87 |
pipe.load_lora_weights(lora_repo)
|
88 |
+
pipe.unet.to("cuda") # Move UNet to GPU
|
89 |
+
pipe.text_encoder.to("cuda") # Move text encoder to GPU
|
90 |
|
91 |
if trigger_word:
|
92 |
positive_prompt = f"{trigger_word} {positive_prompt}"
|
|
|
140 |
run_button = gr.Button("Generate as : ( 1280 x 832 )π€", scale=0, elem_classes="submit-btn")
|
141 |
|
142 |
with gr.Accordion("Advanced options", open=True, visible=True):
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
seed = gr.Slider(
|
144 |
label="Seed",
|
145 |
minimum=0,
|
|
|
191 |
label="Quality Style",
|
192 |
)
|
193 |
|
194 |
+
model_choice = gr.Dropdown(
|
195 |
+
label="LoRA Selection",
|
196 |
+
choices=list(LORA_OPTIONS.keys()),
|
197 |
+
value="Sketch-Smudge"
|
198 |
+
)
|
199 |
|
200 |
with gr.Column(scale=2):
|
201 |
result = gr.Gallery(label="Result", columns=1, show_label=False)
|