Spaces:
Sleeping
Sleeping
update sdxl
Browse files
app.py
CHANGED
@@ -12,6 +12,7 @@ transformers.utils.move_cache()
|
|
12 |
from diffusers import StableDiffusionXLControlNetPipeline, ControlNetModel
|
13 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
14 |
from accelerate import Accelerator
|
|
|
15 |
|
16 |
import warnings
|
17 |
warnings.filterwarnings("ignore")
|
@@ -147,7 +148,7 @@ def colorize_image(input_image, mode):
|
|
147 |
|
148 |
def gradio_interface():
|
149 |
with gr.Blocks() as app:
|
150 |
-
with gr.Tab("
|
151 |
with gr.Blocks():
|
152 |
input_image = gr.Image(type="numpy", label="Upload an Image")
|
153 |
output_modes = gr.Radio(
|
@@ -185,24 +186,29 @@ def gradio_interface():
|
|
185 |
outputs=[resnet_output, mobilenet_output, autoencoder_output]
|
186 |
)
|
187 |
|
188 |
-
with gr.Tab("
|
189 |
with gr.Blocks():
|
190 |
sd_image = gr.Image(label="Upload a Color Image")
|
191 |
positive_prompt = gr.Textbox(label="Positive Prompt", placeholder="Text for positive prompt")
|
192 |
negative_prompt = gr.Textbox(
|
193 |
-
|
194 |
-
|
195 |
)
|
196 |
-
generate_caption = gr.Checkbox(label="Generate Caption?", value=
|
|
|
|
|
|
|
197 |
submit_sd = gr.Button("Generate")
|
198 |
|
|
|
199 |
sd_output_image = gr.Image(label="Colorized Image")
|
200 |
-
sd_caption = gr.Textbox(label="Captioning Result", show_copy_button=True, visible=
|
201 |
|
|
|
202 |
submit_sd.click(
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
)
|
207 |
|
208 |
return app
|
|
|
12 |
from diffusers import StableDiffusionXLControlNetPipeline, ControlNetModel
|
13 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
14 |
from accelerate import Accelerator
|
15 |
+
torch.set_num_threads(2)
|
16 |
|
17 |
import warnings
|
18 |
warnings.filterwarnings("ignore")
|
|
|
148 |
|
149 |
def gradio_interface():
|
150 |
with gr.Blocks() as app:
|
151 |
+
with gr.Tab("Prompt-Free"):
|
152 |
with gr.Blocks():
|
153 |
input_image = gr.Image(type="numpy", label="Upload an Image")
|
154 |
output_modes = gr.Radio(
|
|
|
186 |
outputs=[resnet_output, mobilenet_output, autoencoder_output]
|
187 |
)
|
188 |
|
189 |
+
with gr.Tab("Prompt_Guided(ControlNet-SDXL)"):
|
190 |
with gr.Blocks():
|
191 |
sd_image = gr.Image(label="Upload a Color Image")
|
192 |
positive_prompt = gr.Textbox(label="Positive Prompt", placeholder="Text for positive prompt")
|
193 |
negative_prompt = gr.Textbox(
|
194 |
+
value="low quality, bad quality, low contrast, black and white, bw, monochrome, grainy, blurry, historical, restored, desaturate",
|
195 |
+
label="Negative Prompt", placeholder="Text for negative prompt"
|
196 |
)
|
197 |
+
generate_caption = gr.Checkbox(label="Generate Caption?", value=True)
|
198 |
+
seed = gr.Number(label="Seed", value=123, precision=0)
|
199 |
+
inference_steps = gr.Number(label="Inference Steps", value=5, precision=0)
|
200 |
+
|
201 |
submit_sd = gr.Button("Generate")
|
202 |
|
203 |
+
|
204 |
sd_output_image = gr.Image(label="Colorized Image")
|
205 |
+
sd_caption = gr.Textbox(label="Captioning Result", show_copy_button=True, visible=True)
|
206 |
|
207 |
+
|
208 |
submit_sd.click(
|
209 |
+
fn=colorize_image_sdxl,
|
210 |
+
inputs=[sd_image, positive_prompt, negative_prompt, generate_caption, seed, inference_steps],
|
211 |
+
outputs=[sd_output_image, sd_caption]
|
212 |
)
|
213 |
|
214 |
return app
|