Upload app.py
Browse files
app.py
CHANGED
|
@@ -644,17 +644,17 @@ with EmptyInitWrapper():
|
|
| 644 |
sd = {k.replace("model.", ""): v for k, v in sd.items()}
|
| 645 |
result = model.load_state_dict(sd)
|
| 646 |
|
| 647 |
-
@spaces.GPU(duration=
|
| 648 |
-
@torch.
|
| 649 |
def generate_image(
|
| 650 |
-
prompt, neg_prompt,num_steps ,width, height, guidance, seed,
|
| 651 |
do_img2img, init_image, image2image_strength, resize_img,
|
| 652 |
progress=gr.Progress(track_tqdm=True),
|
| 653 |
):
|
| 654 |
if seed == 0:
|
| 655 |
seed = int(random.random() * 1000000)
|
| 656 |
|
| 657 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 658 |
torch_device = torch.device(device)
|
| 659 |
|
| 660 |
if do_img2img and init_image is not None:
|
|
@@ -709,7 +709,7 @@ def create_demo():
|
|
| 709 |
height = gr.Slider(minimum=128, maximum=2048, step=64, label="Height", value=1024)
|
| 710 |
guidance = gr.Slider(minimum=0.0, maximum=25.0, step=0.1, label="Guidance", value=3.5)
|
| 711 |
seed = gr.Number(label="Seed", precision=-1)
|
| 712 |
-
do_img2img = gr.Checkbox(label="Image to Image", value=False)
|
| 713 |
init_image = gr.Image(label="Input Image", visible=False)
|
| 714 |
image2image_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Noising strength", value=0.8, visible=False)
|
| 715 |
resize_img = gr.Checkbox(label="Resize image", value=True, visible=False)
|
|
|
|
| 644 |
sd = {k.replace("model.", ""): v for k, v in sd.items()}
|
| 645 |
result = model.load_state_dict(sd)
|
| 646 |
|
| 647 |
+
@spaces.GPU(duration=120)
|
| 648 |
+
@torch.inference_mode()
|
| 649 |
def generate_image(
|
| 650 |
+
prompt, neg_prompt, num_steps ,width, height, guidance, seed,
|
| 651 |
do_img2img, init_image, image2image_strength, resize_img,
|
| 652 |
progress=gr.Progress(track_tqdm=True),
|
| 653 |
):
|
| 654 |
if seed == 0:
|
| 655 |
seed = int(random.random() * 1000000)
|
| 656 |
|
| 657 |
+
#device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 658 |
torch_device = torch.device(device)
|
| 659 |
|
| 660 |
if do_img2img and init_image is not None:
|
|
|
|
| 709 |
height = gr.Slider(minimum=128, maximum=2048, step=64, label="Height", value=1024)
|
| 710 |
guidance = gr.Slider(minimum=0.0, maximum=25.0, step=0.1, label="Guidance", value=3.5)
|
| 711 |
seed = gr.Number(label="Seed", precision=-1)
|
| 712 |
+
do_img2img = gr.Checkbox(label="Image to Image", value=False, visible=False)
|
| 713 |
init_image = gr.Image(label="Input Image", visible=False)
|
| 714 |
image2image_strength = gr.Slider(minimum=0.0, maximum=1.0, step=0.01, label="Noising strength", value=0.8, visible=False)
|
| 715 |
resize_img = gr.Checkbox(label="Resize image", value=True, visible=False)
|