fix(api): add pre-converted ControlNets to base sources, add missing ControlNet strings
This commit is contained in:
parent
e8b65f4e01
commit
161913bb7e
|
@ -139,6 +139,7 @@ base_models: Models = {
|
||||||
],
|
],
|
||||||
# download only
|
# download only
|
||||||
"sources": [
|
"sources": [
|
||||||
|
# CodeFormer: no ONNX yet
|
||||||
(
|
(
|
||||||
"detection-resnet50-final",
|
"detection-resnet50-final",
|
||||||
"https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth",
|
"https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/detection_Resnet50_Final.pth",
|
||||||
|
@ -163,6 +164,49 @@ base_models: Models = {
|
||||||
"parsing-parsenet",
|
"parsing-parsenet",
|
||||||
"https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/parsing_parsenet.pth",
|
"https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/parsing_parsenet.pth",
|
||||||
),
|
),
|
||||||
|
# ControlNets: already converted
|
||||||
|
{
|
||||||
|
"dest": "control",
|
||||||
|
"format": "onnx",
|
||||||
|
"name": "canny",
|
||||||
|
"source": "https://huggingface.co/ForserX/sd-controlnet-canny-onnx/resolve/main/model.onnx",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dest": "control",
|
||||||
|
"format": "onnx",
|
||||||
|
"name": "depth",
|
||||||
|
"source": "https://huggingface.co/ForserX/sd-controlnet-depth-onnx/resolve/main/model.onnx",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dest": "control",
|
||||||
|
"format": "onnx",
|
||||||
|
"name": "hed",
|
||||||
|
"source": "https://huggingface.co/ForserX/sd-controlnet-hed-onnx/resolve/main/model.onnx",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dest": "control",
|
||||||
|
"format": "onnx",
|
||||||
|
"name": "mlsd",
|
||||||
|
"source": "https://huggingface.co/ForserX/sd-controlnet-mlsd-onnx/resolve/main/model.onnx",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dest": "control",
|
||||||
|
"format": "onnx",
|
||||||
|
"name": "normal",
|
||||||
|
"source": "https://huggingface.co/ForserX/sd-controlnet-normal-onnx/resolve/main/model.onnx",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dest": "control",
|
||||||
|
"format": "onnx",
|
||||||
|
"name": "openpose",
|
||||||
|
"source": "https://huggingface.co/ForserX/sd-controlnet-openpose-onnx/resolve/main/model.onnx",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dest": "control",
|
||||||
|
"format": "onnx",
|
||||||
|
"name": "seg",
|
||||||
|
"source": "https://huggingface.co/ForserX/sd-controlnet-seg-onnx/resolve/main/model.onnx",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +286,13 @@ def convert_models(conversion: ConversionContext, args, models: Models):
|
||||||
source = model["source"]
|
source = model["source"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dest = fetch_model(conversion, name, source, format=model_format)
|
dest_path = None
|
||||||
|
if "dest" in model:
|
||||||
|
dest_path = path.join(conversion.model_path, model["dest"])
|
||||||
|
|
||||||
|
dest = fetch_model(
|
||||||
|
conversion, name, source, format=model_format, dest=dest_path
|
||||||
|
)
|
||||||
logger.info("finished downloading source: %s -> %s", source, dest)
|
logger.info("finished downloading source: %s -> %s", source, dest)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("error fetching source %s", name)
|
logger.exception("error fetching source %s", name)
|
||||||
|
|
|
@ -44,7 +44,7 @@ def convert_diffusion_control(
|
||||||
if is_torch_2_0:
|
if is_torch_2_0:
|
||||||
controlnet.set_attn_processor(AttnProcessor())
|
controlnet.set_attn_processor(AttnProcessor())
|
||||||
|
|
||||||
cnet_path = output_path / "cnet" / ONNX_MODEL
|
cnet_path = output_path / ONNX_MODEL
|
||||||
onnx_export(
|
onnx_export(
|
||||||
controlnet,
|
controlnet,
|
||||||
model_args=(
|
model_args=(
|
||||||
|
|
|
@ -314,6 +314,7 @@ def convert_diffusion_diffusers(
|
||||||
|
|
||||||
del pipeline.unet
|
del pipeline.unet
|
||||||
|
|
||||||
|
if not single_vae:
|
||||||
convert_diffusion_diffusers_cnet(
|
convert_diffusion_diffusers_cnet(
|
||||||
conversion,
|
conversion,
|
||||||
source,
|
source,
|
||||||
|
@ -325,6 +326,8 @@ def convert_diffusion_diffusers(
|
||||||
num_tokens,
|
num_tokens,
|
||||||
text_hidden_size,
|
text_hidden_size,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
logger.debug("skipping CNet for single-VAE model")
|
||||||
|
|
||||||
if cnet_only:
|
if cnet_only:
|
||||||
logger.info("done converting CNet")
|
logger.info("done converting CNet")
|
||||||
|
|
|
@ -77,7 +77,15 @@ class RRDB(nn.Module):
|
||||||
|
|
||||||
|
|
||||||
class RRDBNet(nn.Module):
|
class RRDBNet(nn.Module):
|
||||||
def __init__(self, num_in_ch=3, num_out_ch=3, num_feat=64, num_block=23, num_grow_ch=32, scale=4):
|
def __init__(
|
||||||
|
self,
|
||||||
|
num_in_ch=3,
|
||||||
|
num_out_ch=3,
|
||||||
|
num_feat=64,
|
||||||
|
num_block=23,
|
||||||
|
num_grow_ch=32,
|
||||||
|
scale=4,
|
||||||
|
):
|
||||||
super(RRDBNet, self).__init__()
|
super(RRDBNet, self).__init__()
|
||||||
RRDB_block_f = functools.partial(RRDB, nf=num_feat, gc=num_grow_ch)
|
RRDB_block_f = functools.partial(RRDB, nf=num_feat, gc=num_grow_ch)
|
||||||
self.sf = scale
|
self.sf = scale
|
||||||
|
|
|
@ -109,6 +109,8 @@ $defs:
|
||||||
type: object
|
type: object
|
||||||
required: [name, source]
|
required: [name, source]
|
||||||
properties:
|
properties:
|
||||||
|
dest:
|
||||||
|
type: string
|
||||||
format:
|
format:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
|
|
|
@ -114,9 +114,11 @@ export const I18N_STRINGS_EN = {
|
||||||
canny: 'Canny Edges',
|
canny: 'Canny Edges',
|
||||||
depth: 'Depth Map',
|
depth: 'Depth Map',
|
||||||
hed: 'HED Edges',
|
hed: 'HED Edges',
|
||||||
|
mlsd: 'M-LSD Segmentation',
|
||||||
normal: 'Normal Map',
|
normal: 'Normal Map',
|
||||||
openpose: 'OpenPose',
|
openpose: 'OpenPose',
|
||||||
scribble: 'Scribble',
|
scribble: 'Scribble',
|
||||||
|
segment: 'Image Segmentation',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modelType: {
|
modelType: {
|
||||||
|
@ -244,17 +246,17 @@ export const I18N_STRINGS_EN = {
|
||||||
},
|
},
|
||||||
sourceFilter: {
|
sourceFilter: {
|
||||||
none: 'None',
|
none: 'None',
|
||||||
gaussian: 'Gaussian Blur',
|
canny: 'Canny Edges',
|
||||||
noise: 'Histogram Noise',
|
depth: 'Depth Map',
|
||||||
face: 'Face Detection',
|
face: 'Face Detection',
|
||||||
segment: 'Image Segmentation',
|
gaussian: 'Gaussian Blur',
|
||||||
|
hed: 'HED Edges',
|
||||||
mlsd: 'M-LSD Segmentation',
|
mlsd: 'M-LSD Segmentation',
|
||||||
normal: 'Normal Map',
|
normal: 'Normal Map',
|
||||||
hed: 'HED Edges',
|
noise: 'Histogram Noise',
|
||||||
scribble: 'Scribble',
|
|
||||||
depth: 'Depth Map',
|
|
||||||
canny: 'Canny Edges',
|
|
||||||
openpose: 'OpenPose',
|
openpose: 'OpenPose',
|
||||||
|
scribble: 'Scribble',
|
||||||
|
segment: 'Image Segmentation',
|
||||||
},
|
},
|
||||||
tab: {
|
tab: {
|
||||||
blend: 'Blend',
|
blend: 'Blend',
|
||||||
|
|
Loading…
Reference in New Issue