Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,7 +34,7 @@ import numpy as np
|
|
| 34 |
import cv2
|
| 35 |
import os
|
| 36 |
import random
|
| 37 |
-
|
| 38 |
|
| 39 |
style_list = [
|
| 40 |
{
|
|
@@ -143,7 +143,7 @@ def preprocess_image(image: Image.Image,
|
|
| 143 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
| 144 |
|
| 145 |
print("params:", prompt, negative_prompt, style_name, num_steps, guidance_scale, controlnet_conditioning_scale)
|
| 146 |
-
|
| 147 |
prompt=prompt,
|
| 148 |
negative_prompt=negative_prompt,
|
| 149 |
image=image,
|
|
@@ -154,8 +154,8 @@ def preprocess_image(image: Image.Image,
|
|
| 154 |
height=new_height).images[0]
|
| 155 |
|
| 156 |
|
| 157 |
-
processed_image = pipeline.preprocess_image(
|
| 158 |
-
return processed_image
|
| 159 |
|
| 160 |
|
| 161 |
def preprocess_images(images: List[Tuple[Image.Image, str]]) -> List[Image.Image]:
|
|
@@ -254,7 +254,7 @@ def image_to_3d(
|
|
| 254 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
| 255 |
if not is_multiimage:
|
| 256 |
outputs = pipeline.run(
|
| 257 |
-
image['composite'],
|
| 258 |
seed=seed,
|
| 259 |
formats=["gaussian", "mesh"],
|
| 260 |
preprocess_image=False,
|
|
@@ -387,6 +387,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
| 387 |
#image_prompt = gr.Image(label="Image Prompt", format="png", image_mode="RGBA", type="pil", height=300)
|
| 388 |
with gr.Column():
|
| 389 |
image_prompt = gr.ImageMask(type="pil", image_mode="RGB", height=512, value={"background":Image.new("RGB", (512, 512), (255, 255, 255)), "layers":[Image.new("RGB", (512, 512), (255, 255, 255))], "composite":Image.new("RGB", (512, 512), (255, 255, 255))})
|
|
|
|
| 390 |
with gr.Row():
|
| 391 |
sketch_btn = gr.Button("process sketch")
|
| 392 |
generate_btn = gr.Button("Generate 3D")
|
|
@@ -517,7 +518,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
| 517 |
).then(
|
| 518 |
preprocess_image,
|
| 519 |
inputs=[image_prompt, prompt, negative_prompt, style, num_steps, guidance_scale, controlnet_conditioning_scale],
|
| 520 |
-
outputs=[
|
| 521 |
)
|
| 522 |
multiimage_prompt.upload(
|
| 523 |
preprocess_images,
|
|
@@ -531,7 +532,7 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
| 531 |
outputs=[seed],
|
| 532 |
).then(
|
| 533 |
image_to_3d,
|
| 534 |
-
inputs=[
|
| 535 |
outputs=[output_buf, video_output],
|
| 536 |
).then(
|
| 537 |
lambda: tuple([gr.Button(interactive=True), gr.Button(interactive=True)]),
|
|
|
|
| 34 |
import cv2
|
| 35 |
import os
|
| 36 |
import random
|
| 37 |
+
from gradio_imageslider import ImageSlider
|
| 38 |
|
| 39 |
style_list = [
|
| 40 |
{
|
|
|
|
| 143 |
prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
| 144 |
|
| 145 |
print("params:", prompt, negative_prompt, style_name, num_steps, guidance_scale, controlnet_conditioning_scale)
|
| 146 |
+
output = pipe_control(
|
| 147 |
prompt=prompt,
|
| 148 |
negative_prompt=negative_prompt,
|
| 149 |
image=image,
|
|
|
|
| 154 |
height=new_height).images[0]
|
| 155 |
|
| 156 |
|
| 157 |
+
processed_image = pipeline.preprocess_image(output)
|
| 158 |
+
return (image, processed_image)
|
| 159 |
|
| 160 |
|
| 161 |
def preprocess_images(images: List[Tuple[Image.Image, str]]) -> List[Image.Image]:
|
|
|
|
| 254 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
| 255 |
if not is_multiimage:
|
| 256 |
outputs = pipeline.run(
|
| 257 |
+
image[1]['composite'],
|
| 258 |
seed=seed,
|
| 259 |
formats=["gaussian", "mesh"],
|
| 260 |
preprocess_image=False,
|
|
|
|
| 387 |
#image_prompt = gr.Image(label="Image Prompt", format="png", image_mode="RGBA", type="pil", height=300)
|
| 388 |
with gr.Column():
|
| 389 |
image_prompt = gr.ImageMask(type="pil", image_mode="RGB", height=512, value={"background":Image.new("RGB", (512, 512), (255, 255, 255)), "layers":[Image.new("RGB", (512, 512), (255, 255, 255))], "composite":Image.new("RGB", (512, 512), (255, 255, 255))})
|
| 390 |
+
image_prompt_processed = ImageSlider(type="pil", height=512)
|
| 391 |
with gr.Row():
|
| 392 |
sketch_btn = gr.Button("process sketch")
|
| 393 |
generate_btn = gr.Button("Generate 3D")
|
|
|
|
| 518 |
).then(
|
| 519 |
preprocess_image,
|
| 520 |
inputs=[image_prompt, prompt, negative_prompt, style, num_steps, guidance_scale, controlnet_conditioning_scale],
|
| 521 |
+
outputs=[image_prompt_processed],
|
| 522 |
)
|
| 523 |
multiimage_prompt.upload(
|
| 524 |
preprocess_images,
|
|
|
|
| 532 |
outputs=[seed],
|
| 533 |
).then(
|
| 534 |
image_to_3d,
|
| 535 |
+
inputs=[image_prompt_processed, multiimage_prompt, is_multiimage, seed, ss_guidance_strength, ss_sampling_steps, slat_guidance_strength, slat_sampling_steps, multiimage_algo],
|
| 536 |
outputs=[output_buf, video_output],
|
| 537 |
).then(
|
| 538 |
lambda: tuple([gr.Button(interactive=True), gr.Button(interactive=True)]),
|