Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fengzch-das
nunchaku
Commits
741ec912
Commit
741ec912
authored
Nov 07, 2024
by
Muyang Li
Browse files
increase the line thickness for better use experience
parent
4e668794
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
app/i2i/flux_pix2pix_pipeline.py
app/i2i/flux_pix2pix_pipeline.py
+17
-0
app/i2i/run_gradio.py
app/i2i/run_gradio.py
+1
-1
No files found.
app/i2i/flux_pix2pix_pipeline.py
View file @
741ec912
...
@@ -3,11 +3,13 @@ from typing import Any, Callable, Optional, Union
...
@@ -3,11 +3,13 @@ from typing import Any, Callable, Optional, Union
import
torch
import
torch
import
torchvision.transforms.functional
as
F
import
torchvision.transforms.functional
as
F
import
torchvision.utils
from
PIL
import
Image
from
PIL
import
Image
from
diffusers.pipelines.flux.pipeline_flux
import
FluxPipeline
,
FluxPipelineOutput
,
FluxTransformer2DModel
from
diffusers.pipelines.flux.pipeline_flux
import
FluxPipeline
,
FluxPipelineOutput
,
FluxTransformer2DModel
from
einops
import
rearrange
from
einops
import
rearrange
from
huggingface_hub
import
hf_hub_download
from
huggingface_hub
import
hf_hub_download
from
peft.tuners
import
lora
from
peft.tuners
import
lora
from
torch
import
nn
from
nunchaku.models.flux
import
inject_pipeline
,
load_quantized_model
from
nunchaku.models.flux
import
inject_pipeline
,
load_quantized_model
from
nunchaku.pipelines.flux
import
quantize_t5
from
nunchaku.pipelines.flux
import
quantize_t5
...
@@ -134,6 +136,21 @@ class FluxPix2pixTurboPipeline(FluxPipeline):
...
@@ -134,6 +136,21 @@ class FluxPix2pixTurboPipeline(FluxPipeline):
image
=
image
.
resize
((
width
,
height
),
Image
.
LANCZOS
)
image
=
image
.
resize
((
width
,
height
),
Image
.
LANCZOS
)
image_t
=
F
.
to_tensor
(
image
)
<
0.5
image_t
=
F
.
to_tensor
(
image
)
<
0.5
image_t
=
image_t
.
unsqueeze
(
0
).
to
(
self
.
dtype
).
to
(
device
)
image_t
=
image_t
.
unsqueeze
(
0
).
to
(
self
.
dtype
).
to
(
device
)
kernel_size
=
4
if
hasattr
(
self
,
"erosion_kernel"
):
erosion_kernel
=
self
.
erosion_kernel
else
:
erosion_kernel
=
torch
.
ones
(
1
,
1
,
kernel_size
,
kernel_size
,
dtype
=
self
.
dtype
,
device
=
device
)
self
.
erosion_kernel
=
erosion_kernel
torchvision
.
utils
.
save_image
(
image_t
[
0
],
"before.png"
)
image_t
=
(
nn
.
functional
.
conv2d
(
image_t
[:,
:
1
],
erosion_kernel
,
padding
=
kernel_size
//
2
)
>
kernel_size
**
2
-
0.1
)
image_t
=
torch
.
concat
([
image_t
,
image_t
,
image_t
],
dim
=
1
).
to
(
self
.
dtype
)
torchvision
.
utils
.
save_image
(
image_t
[
0
],
"after.png"
)
image_t
=
(
image_t
-
0.5
)
*
2
image_t
=
(
image_t
-
0.5
)
*
2
# 4. Prepare latent variables
# 4. Prepare latent variables
...
...
app/i2i/run_gradio.py
View file @
741ec912
...
@@ -117,7 +117,7 @@ with gr.Blocks(css_paths="assets/style.css", title=f"SVDQuant Sketch-to-Image De
...
@@ -117,7 +117,7 @@ with gr.Blocks(css_paths="assets/style.css", title=f"SVDQuant Sketch-to-Image De
transforms
=
[],
transforms
=
[],
canvas_size
=
(
1024
,
1024
),
canvas_size
=
(
1024
,
1024
),
scale
=
1
,
scale
=
1
,
brush
=
gr
.
Brush
(
default_size
=
1
,
colors
=
[
"#000000"
],
color_mode
=
"fixed"
),
brush
=
gr
.
Brush
(
default_size
=
3
,
colors
=
[
"#000000"
],
color_mode
=
"fixed"
),
format
=
"png"
,
format
=
"png"
,
layers
=
False
,
layers
=
False
,
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment