Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
08df63a
1
Parent(s):
51838d1
app.py
Browse files
app.py
CHANGED
@@ -44,13 +44,13 @@ def load_model(lora_dir, cn_dir):
|
|
44 |
|
45 |
|
46 |
@spaces.GPU
|
47 |
-
def predict(input_image_path,
|
48 |
pipe = load_model(lora_dir, cn_dir)
|
49 |
input_image_pil = Image.open(input_image_path)
|
50 |
base_size = input_image_pil.size
|
51 |
resize_image = resize_image_aspect_ratio(input_image_pil)
|
52 |
white_base_pil = base_generation(resize_image.size, (255, 255, 255, 255)).convert("RGB")
|
53 |
-
|
54 |
generator = torch.manual_seed(0)
|
55 |
last_time = time.time()
|
56 |
prompt = "masterpiece, best quality, monochrome, lineart, white background, " + prompt
|
@@ -61,8 +61,8 @@ def predict(input_image_path, canny_image, prompt, negative_prompt, controlnet_s
|
|
61 |
print(prompt)
|
62 |
|
63 |
output_image = pipe(
|
64 |
-
image=
|
65 |
-
control_image=
|
66 |
strength=1.0,
|
67 |
prompt=prompt,
|
68 |
negative_prompt = negative_prompt,
|
@@ -112,11 +112,11 @@ class Img2Img:
|
|
112 |
with gr.Row():
|
113 |
with gr.Column():
|
114 |
self.input_image_path = gr.Image(label="input_image", type='filepath')
|
115 |
-
self.
|
116 |
with gr.Row():
|
117 |
-
line_sigma = gr.Slider(minimum=0.1, value=1.4, maximum=3.0, show_label=False)
|
118 |
-
line_gamma = gr.Slider(minimum=0.5, value=0.98, maximum=2.0, show_label=False)
|
119 |
-
|
120 |
|
121 |
self.prompt = gr.Textbox(label="prompt", lines=3)
|
122 |
self.negative_prompt = gr.Textbox(label="negative_prompt", lines=3, value="lowres, error, extra digit, fewer digits, cropped, worst quality,low quality, normal quality, jpeg artifacts, blurry")
|
@@ -129,10 +129,10 @@ class Img2Img:
|
|
129 |
with gr.Column():
|
130 |
self.output_image = gr.Image(type="pil", label="output_image")
|
131 |
|
132 |
-
|
133 |
self._make_line,
|
134 |
inputs=[self.input_image_path, line_sigma, line_gamma],
|
135 |
-
outputs=self.
|
136 |
)
|
137 |
|
138 |
|
|
|
44 |
|
45 |
|
46 |
@spaces.GPU
|
47 |
+
def predict(input_image_path, line_image, prompt, negative_prompt, controlnet_scale):
|
48 |
pipe = load_model(lora_dir, cn_dir)
|
49 |
input_image_pil = Image.open(input_image_path)
|
50 |
base_size = input_image_pil.size
|
51 |
resize_image = resize_image_aspect_ratio(input_image_pil)
|
52 |
white_base_pil = base_generation(resize_image.size, (255, 255, 255, 255)).convert("RGB")
|
53 |
+
line_image = line_image.resize(resize_image.size, Image.LANCZOS)
|
54 |
generator = torch.manual_seed(0)
|
55 |
last_time = time.time()
|
56 |
prompt = "masterpiece, best quality, monochrome, lineart, white background, " + prompt
|
|
|
61 |
print(prompt)
|
62 |
|
63 |
output_image = pipe(
|
64 |
+
image=line_image,
|
65 |
+
control_image=line_image,
|
66 |
strength=1.0,
|
67 |
prompt=prompt,
|
68 |
negative_prompt = negative_prompt,
|
|
|
112 |
with gr.Row():
|
113 |
with gr.Column():
|
114 |
self.input_image_path = gr.Image(label="input_image", type='filepath')
|
115 |
+
self.line_image = gr.Image(label="line_image", type='pil')
|
116 |
with gr.Row():
|
117 |
+
line_sigma = gr.Slider(label="sigma", minimum=0.1, value=1.4, maximum=3.0, show_label=False)
|
118 |
+
line_gamma = gr.Slider(label="gamma", minimum=0.5, value=0.98, maximum=2.0, show_label=False)
|
119 |
+
line_generate_button = gr.Button("line_generate")
|
120 |
|
121 |
self.prompt = gr.Textbox(label="prompt", lines=3)
|
122 |
self.negative_prompt = gr.Textbox(label="negative_prompt", lines=3, value="lowres, error, extra digit, fewer digits, cropped, worst quality,low quality, normal quality, jpeg artifacts, blurry")
|
|
|
129 |
with gr.Column():
|
130 |
self.output_image = gr.Image(type="pil", label="output_image")
|
131 |
|
132 |
+
line_generate_button.click(
|
133 |
self._make_line,
|
134 |
inputs=[self.input_image_path, line_sigma, line_gamma],
|
135 |
+
outputs=self.line_image
|
136 |
)
|
137 |
|
138 |
|