Instructions to use gingyin/TTPLanet_SDXL_Controlnet_Tile_Realistic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use gingyin/TTPLanet_SDXL_Controlnet_Tile_Realistic with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("gingyin/TTPLanet_SDXL_Controlnet_Tile_Realistic", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Duplicate from TTPlanet/TTPLanet_SDXL_Controlnet_Tile_Realistic
Browse filesCo-authored-by: Aaron Xie <TTPlanet@users.noreply.huggingface.co>
- .gitattributes +35 -0
- README.md +116 -0
- TTPLANET_Controlnet_Tile_realistic_v1_fp16.safetensors +3 -0
- TTPLANET_Controlnet_Tile_realistic_v1_fp32.safetensors +3 -0
- TTPLANET_Controlnet_Tile_realistic_v2_fp16.safetensors +3 -0
- TTPLANET_Controlnet_Tile_realistic_v2_rank256.safetensors +3 -0
- TTP_tile_preprocessor_v5.py +191 -0
- config.json +57 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: diffusers
|
| 3 |
+
pipeline_tag: image-feature-extraction
|
| 4 |
+
tags:
|
| 5 |
+
- Controlnet
|
| 6 |
+
- Tile
|
| 7 |
+
- stable diffustion
|
| 8 |
+
license: openrail
|
| 9 |
+
---
|
| 10 |
+
# Model Card for Model ID
|
| 11 |
+
|
| 12 |
+
<!-- Provide a quick summary of what the model is/does. -->
|
| 13 |
+
Controlnet SDXL Tile model realistic version, fit for both webui extention and comfyui controlnet node.
|
| 14 |
+
|
| 15 |
+
### Model Description
|
| 16 |
+
|
| 17 |
+
Here's a refined version of the update notes for the Tile V2:
|
| 18 |
+
|
| 19 |
+
-Introducing the new Tile V2, enhanced with a vastly improved training dataset and more extensive training steps.
|
| 20 |
+
|
| 21 |
+
-The Tile V2 now automatically recognizes a wider range of objects without needing explicit prompts.
|
| 22 |
+
|
| 23 |
+
-I've made significant improvements to the color offset issue. if you are still seeing the significant offset, it's normal, just adding the prompt or use a color fix node.
|
| 24 |
+
|
| 25 |
+
-The control strength is more robust, allowing it to replace canny+openpose in some conditions.
|
| 26 |
+
|
| 27 |
+
If you encounter the edge halo issue with t2i or i2i, particularly with i2i, ensure that the preprocessing provides the controlnet image with sufficient blurring. If the output is too sharp, it may result in a 'halo'—a pronounced shape around the edges with high contrast. In such cases, apply some blur before sending it to the controlnet. If the output is too blurry, this could be due to excessive blurring during preprocessing, or the original picture may be too small.
|
| 28 |
+
|
| 29 |
+
Enjoy the enhanced capabilities of Tile V2!
|
| 30 |
+
|
| 31 |
+

|
| 32 |
+
|
| 33 |
+
![Q5A0[{{0{]I~`KJFCZJ7`}4.jpg](https://cdn-uploads.huggingface.co/production/uploads/641edd91eefe94aff6de024c/HMGmYz7IiLSqfoiMgcmgU.jpeg)
|
| 34 |
+
|
| 35 |
+
<!-- Provide a longer summary of what this model is. -->
|
| 36 |
+
- This is a SDXL based controlnet Tile model, trained with huggingface diffusers sets, fit for Stable diffusion SDXL controlnet.
|
| 37 |
+
- It is original trained for my personal realistic model project used for Ultimate upscale process to boost the picture details. with a proper workflow, it can provide a good result for high detailed, high resolution image fix.
|
| 38 |
+
- As there is no SDXL Tile available from the most open source, I decide to share this one out.
|
| 39 |
+
- I will share my workflow soon as I am still working on it to have better result.
|
| 40 |
+
- **I am still working on the better workflow for super upscale as I showed in the example, trust me, it's all real!!! and Enjoy**
|
| 41 |
+
-
|
| 42 |
+

|
| 43 |
+

|
| 44 |
+

|
| 45 |
+

|
| 46 |
+

|
| 47 |
+

|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
- **Developed by:** TTPlanet
|
| 51 |
+
- **Model type:** Controlnet Tile
|
| 52 |
+
- **Language(s) (NLP):** No language limitation
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
## Uses
|
| 56 |
+
- **Important: Tile model is not a upscale model!!! it enhance or change the detial of the original size image, remember this before you use it!**
|
| 57 |
+
- This model will not significant change the base model style. it only adding the features to the upscaled pixel blocks....
|
| 58 |
+
- --Just use a regular controlnet model in Webui by select as tile model and use tile_resample for Ultimate Upscale script.
|
| 59 |
+
- --Just use load controlnet model in comfyui and apply to control net condition.
|
| 60 |
+
- --if you try to use it in webui t2i, need proper prompt setup, otherwise it will significant modify the original image color. I don't know the reason, as I don't really use this function.
|
| 61 |
+
- --it do perform much better with the image from the datasets. However, everything works fine for the i2i model and what is the place usually the ultimate upscale is applied!!
|
| 62 |
+
- **--Please also notice this is a realistic training set, so no comic, animation application are promised.**
|
| 63 |
+
- --For tile upscale, set the denoise around 0.3-0.4 to get good result.
|
| 64 |
+
- --For controlnet strength, set to 0.9 will be better choice
|
| 65 |
+
- --For human image fix, IPA and early stop on controlnet will provide better reslut
|
| 66 |
+
- **--Pickup a good realistic base model is important!**
|
| 67 |
+

|
| 68 |
+

|
| 69 |
+
- **bsides the basic function, Tile can also change the picture style based on you model, please select the preprocessor as None(not resample!!!!) you can build different style from one single picture with great control!**
|
| 70 |
+
- Just enjoy
|
| 71 |
+

|
| 72 |
+
-
|
| 73 |
+
- **additional instruction to use this tile**
|
| 74 |
+
- **Part 1:update for style change application instruction(**cloth change and keep consistent pose**):**
|
| 75 |
+
|
| 76 |
+
- 1. Open a A1111 webui.
|
| 77 |
+
|
| 78 |
+
- 2. select a image you want to use for controlnet tile
|
| 79 |
+
|
| 80 |
+
- 3. remember the setting is like this, make 100% preprocessor is none. and control mode is My prompt is more important.
|
| 81 |
+
|
| 82 |
+

|
| 83 |
+
|
| 84 |
+
- 4. type in the prompts in positive and negative text box, gen the image as you wish. if you want to change the cloth, type like a woman dressed in yellow T-shirt, and change the background like in a shopping mall,
|
| 85 |
+
|
| 86 |
+
- 5. Hires fix is supported!!!
|
| 87 |
+
|
| 88 |
+
- 6. You will get the result as below:
|
| 89 |
+
|
| 90 |
+

|
| 91 |
+

|
| 92 |
+
|
| 93 |
+
- **Part2: for ultimate sd upscale application**
|
| 94 |
+
|
| 95 |
+
Here is the simplified workflow just for ultimate upscale, you can modify and add pre process for your image based on the real condition. In my case, I usually make a image to image with 0.1 denoise rate for the real low quality image such as 600*400 to 1200*800 before I through it into this ultimate upscale process.
|
| 96 |
+
|
| 97 |
+
Please add IPA process if you need the face likes identical, please also add IPA in the raw pre process for low quality image i2i. Remember, over resolution than downscale is always the best way to boost the quality from low resolution image.
|
| 98 |
+
|
| 99 |
+
https://civitai.com/models/333060/simplified-workflow-for-ultimate-sd-upscale
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
## Bias, Risks, and Limitations
|
| 103 |
+
|
| 104 |
+
- **Please do not use it for adult content**
|
| 105 |
+
|
| 106 |
+
### Recommendations
|
| 107 |
+
|
| 108 |
+
- Use comfyui to build your own Upscale process, it works fine!!!
|
| 109 |
+
|
| 110 |
+
- **Special thanks to the Controlnet builder lllyasviel Lvmin Zhang (Lyumin Zhang) who bring so much fun to us, and thanks huggingface make the training set to make the training so smooth.**
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
## Model Card Contact
|
| 114 |
+
|
| 115 |
+
--contact me if you want, discord with "ttplanet", Civitai with "ttplanet"
|
| 116 |
+
--you can also join the group discussion with QQ gourp number: 294060503
|
TTPLANET_Controlnet_Tile_realistic_v1_fp16.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fa2a5f2fec814819c835403c778be2c2437d147931921304569fccec2b45173c
|
| 3 |
+
size 2502139104
|
TTPLANET_Controlnet_Tile_realistic_v1_fp32.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f33012cbac5839885f143aa2accb2e403414c7dad119364bbe18de37e4a65f67
|
| 3 |
+
size 5004167864
|
TTPLANET_Controlnet_Tile_realistic_v2_fp16.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3d7db14f6b82c981f506be138774f6d9324dd2087a193e79682b4856ec90a622
|
| 3 |
+
size 2502139104
|
TTPLANET_Controlnet_Tile_realistic_v2_rank256.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:093d5b1c50055e57f85ee7dbf0104e6e8ae7f9dd589a6502c413146b516c6fcb
|
| 3 |
+
size 774423024
|
TTP_tile_preprocessor_v5.py
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import torch
|
| 5 |
+
|
| 6 |
+
def pil2tensor(image: Image) -> torch.Tensor:
|
| 7 |
+
return torch.from_numpy(np.array(image).astype(np.float32) / 255.0).unsqueeze(0)
|
| 8 |
+
|
| 9 |
+
def tensor2pil(t_image: torch.Tensor) -> Image:
|
| 10 |
+
return Image.fromarray(np.clip(255.0 * t_image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
|
| 11 |
+
|
| 12 |
+
def apply_gaussian_blur(image_np, ksize=5, sigmaX=1.0):
|
| 13 |
+
if ksize % 2 == 0:
|
| 14 |
+
ksize += 1 # ksize must be odd
|
| 15 |
+
blurred_image = cv2.GaussianBlur(image_np, (ksize, ksize), sigmaX=sigmaX)
|
| 16 |
+
return blurred_image
|
| 17 |
+
|
| 18 |
+
def apply_guided_filter(image_np, radius, eps):
|
| 19 |
+
# Convert image to float32 for the guided filter
|
| 20 |
+
image_np_float = np.float32(image_np) / 255.0
|
| 21 |
+
# Apply the guided filter
|
| 22 |
+
filtered_image = cv2.ximgproc.guidedFilter(image_np_float, image_np_float, radius, eps)
|
| 23 |
+
# Scale back to uint8
|
| 24 |
+
filtered_image = np.clip(filtered_image * 255, 0, 255).astype(np.uint8)
|
| 25 |
+
return filtered_image
|
| 26 |
+
|
| 27 |
+
class TTPlanet_Tile_Preprocessor_GF:
|
| 28 |
+
def __init__(self, blur_strength=3.0, radius=7, eps=0.01):
|
| 29 |
+
self.blur_strength = blur_strength
|
| 30 |
+
self.radius = radius
|
| 31 |
+
self.eps = eps
|
| 32 |
+
|
| 33 |
+
@classmethod
|
| 34 |
+
def INPUT_TYPES(cls):
|
| 35 |
+
return {
|
| 36 |
+
"required": {
|
| 37 |
+
"image": ("IMAGE",),
|
| 38 |
+
"scale_factor": ("FLOAT", {"default": 1.00, "min": 1.00, "max": 8.00, "step": 0.05}),
|
| 39 |
+
"blur_strength": ("FLOAT", {"default": 2.0, "min": 1.0, "max": 10.0, "step": 0.1}),
|
| 40 |
+
"radius": ("INT", {"default": 7, "min": 1, "max": 20, "step": 1}),
|
| 41 |
+
"eps": ("FLOAT", {"default": 0.01, "min": 0.001, "max": 0.1, "step": 0.001}),
|
| 42 |
+
},
|
| 43 |
+
"optional": {}
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
RETURN_TYPES = ("IMAGE",)
|
| 47 |
+
RETURN_NAMES = ("image_output",)
|
| 48 |
+
FUNCTION = 'process_image'
|
| 49 |
+
CATEGORY = 'TTP_TILE'
|
| 50 |
+
|
| 51 |
+
def process_image(self, image, scale_factor, blur_strength, radius, eps):
|
| 52 |
+
ret_images = []
|
| 53 |
+
|
| 54 |
+
for i in image:
|
| 55 |
+
# Convert tensor to PIL for processing
|
| 56 |
+
_canvas = tensor2pil(torch.unsqueeze(i, 0)).convert('RGB')
|
| 57 |
+
img_np = np.array(_canvas)[:, :, ::-1] # RGB to BGR
|
| 58 |
+
|
| 59 |
+
# Apply Gaussian blur
|
| 60 |
+
img_np = apply_gaussian_blur(img_np, ksize=int(blur_strength), sigmaX=blur_strength / 2)
|
| 61 |
+
|
| 62 |
+
# Apply Guided Filter
|
| 63 |
+
img_np = apply_guided_filter(img_np, radius, eps)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# Resize image
|
| 67 |
+
height, width = img_np.shape[:2]
|
| 68 |
+
new_width = int(width / scale_factor)
|
| 69 |
+
new_height = int(height / scale_factor)
|
| 70 |
+
resized_down = cv2.resize(img_np, (new_width, new_height), interpolation=cv2.INTER_AREA)
|
| 71 |
+
resized_img = cv2.resize(resized_down, (width, height), interpolation=cv2.INTER_CUBIC)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
# Convert OpenCV back to PIL and then to tensor
|
| 76 |
+
pil_img = Image.fromarray(resized_img[:, :, ::-1]) # BGR to RGB
|
| 77 |
+
tensor_img = pil2tensor(pil_img)
|
| 78 |
+
ret_images.append(tensor_img)
|
| 79 |
+
|
| 80 |
+
return (torch.cat(ret_images, dim=0),)
|
| 81 |
+
|
| 82 |
+
class TTPlanet_Tile_Preprocessor_Simple:
|
| 83 |
+
def __init__(self, blur_strength=3.0):
|
| 84 |
+
self.blur_strength = blur_strength
|
| 85 |
+
|
| 86 |
+
@classmethod
|
| 87 |
+
def INPUT_TYPES(cls):
|
| 88 |
+
return {
|
| 89 |
+
"required": {
|
| 90 |
+
"image": ("IMAGE",),
|
| 91 |
+
"scale_factor": ("FLOAT", {"default": 2.00, "min": 1.00, "max": 8.00, "step": 0.05}),
|
| 92 |
+
"blur_strength": ("FLOAT", {"default": 1.0, "min": 1.0, "max": 20.0, "step": 0.1}),
|
| 93 |
+
},
|
| 94 |
+
"optional": {}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
RETURN_TYPES = ("IMAGE",)
|
| 98 |
+
RETURN_NAMES = ("image_output",)
|
| 99 |
+
FUNCTION = 'process_image'
|
| 100 |
+
CATEGORY = 'TTP_TILE'
|
| 101 |
+
|
| 102 |
+
def process_image(self, image, scale_factor, blur_strength):
|
| 103 |
+
ret_images = []
|
| 104 |
+
|
| 105 |
+
for i in image:
|
| 106 |
+
# Convert tensor to PIL for processing
|
| 107 |
+
_canvas = tensor2pil(torch.unsqueeze(i, 0)).convert('RGB')
|
| 108 |
+
|
| 109 |
+
# Convert PIL image to OpenCV format
|
| 110 |
+
img_np = np.array(_canvas)[:, :, ::-1] # RGB to BGR
|
| 111 |
+
|
| 112 |
+
# Resize image first if you want blur to apply after resizing
|
| 113 |
+
height, width = img_np.shape[:2]
|
| 114 |
+
new_width = int(width / scale_factor)
|
| 115 |
+
new_height = int(height / scale_factor)
|
| 116 |
+
resized_down = cv2.resize(img_np, (new_width, new_height), interpolation=cv2.INTER_AREA)
|
| 117 |
+
resized_img = cv2.resize(resized_down, (width, height), interpolation=cv2.INTER_LANCZOS4)
|
| 118 |
+
|
| 119 |
+
# Apply Gaussian blur after resizing
|
| 120 |
+
img_np = apply_gaussian_blur(resized_img, ksize=int(blur_strength), sigmaX=blur_strength / 2)
|
| 121 |
+
|
| 122 |
+
# Convert OpenCV back to PIL and then to tensor
|
| 123 |
+
_canvas = Image.fromarray(img_np[:, :, ::-1]) # BGR to RGB
|
| 124 |
+
tensor_img = pil2tensor(_canvas)
|
| 125 |
+
ret_images.append(tensor_img)
|
| 126 |
+
|
| 127 |
+
return (torch.cat(ret_images, dim=0),)
|
| 128 |
+
|
| 129 |
+
class TTPlanet_Tile_Preprocessor_cufoff:
|
| 130 |
+
def __init__(self, blur_strength=3.0, cutoff_frequency=30, filter_strength=1.0):
|
| 131 |
+
self.blur_strength = blur_strength
|
| 132 |
+
self.cutoff_frequency = cutoff_frequency
|
| 133 |
+
self.filter_strength = filter_strength
|
| 134 |
+
|
| 135 |
+
@classmethod
|
| 136 |
+
def INPUT_TYPES(cls):
|
| 137 |
+
return {
|
| 138 |
+
"required": {
|
| 139 |
+
"image": ("IMAGE",),
|
| 140 |
+
"scale_factor": ("FLOAT", {"default": 1.00, "min": 1.00, "max": 8.00, "step": 0.05}),
|
| 141 |
+
"blur_strength": ("FLOAT", {"default": 2.0, "min": 1.0, "max": 10.0, "step": 0.1}),
|
| 142 |
+
"cutoff_frequency": ("INT", {"default": 100, "min": 0, "max": 256, "step": 1}),
|
| 143 |
+
"filter_strength": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 10.0, "step": 0.1}),
|
| 144 |
+
},
|
| 145 |
+
"optional": {}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
RETURN_TYPES = ("IMAGE",)
|
| 149 |
+
RETURN_NAMES = ("image_output",)
|
| 150 |
+
FUNCTION = 'process_image'
|
| 151 |
+
CATEGORY = 'TTP_TILE'
|
| 152 |
+
|
| 153 |
+
def process_image(self, image, scale_factor, blur_strength, cutoff_frequency, filter_strength):
|
| 154 |
+
ret_images = []
|
| 155 |
+
|
| 156 |
+
for i in image:
|
| 157 |
+
# Convert tensor to PIL for processing
|
| 158 |
+
_canvas = tensor2pil(torch.unsqueeze(i, 0)).convert('RGB')
|
| 159 |
+
img_np = np.array(_canvas)[:, :, ::-1] # RGB to BGR
|
| 160 |
+
|
| 161 |
+
# Apply low pass filter with new strength parameter
|
| 162 |
+
img_np = apply_low_pass_filter(img_np, cutoff_frequency, filter_strength)
|
| 163 |
+
|
| 164 |
+
# Resize image
|
| 165 |
+
height, width = img_np.shape[:2]
|
| 166 |
+
new_width = int(width / scale_factor)
|
| 167 |
+
new_height = int(height / scale_factor)
|
| 168 |
+
resized_down = cv2.resize(img_np, (new_width, new_height), interpolation=cv2.INTER_AREA)
|
| 169 |
+
resized_img = cv2.resize(resized_down, (width, height), interpolation=cv2.INTER_LANCZOS4)
|
| 170 |
+
|
| 171 |
+
# Apply Gaussian blur
|
| 172 |
+
img_np = apply_gaussian_blur(img_np, ksize=int(blur_strength), sigmaX=blur_strength / 2)
|
| 173 |
+
|
| 174 |
+
# Convert OpenCV back to PIL and then to tensor
|
| 175 |
+
pil_img = Image.fromarray(resized_img[:, :, ::-1]) # BGR to RGB
|
| 176 |
+
tensor_img = pil2tensor(pil_img)
|
| 177 |
+
ret_images.append(tensor_img)
|
| 178 |
+
|
| 179 |
+
return (torch.cat(ret_images, dim=0),)
|
| 180 |
+
|
| 181 |
+
NODE_CLASS_MAPPINGS = {
|
| 182 |
+
"TTPlanet_Tile_Preprocessor_GF": TTPlanet_Tile_Preprocessor_GF,
|
| 183 |
+
"TTPlanet_Tile_Preprocessor_Simple": TTPlanet_Tile_Preprocessor_Simple,
|
| 184 |
+
"TTPlanet_Tile_Preprocessor_cufoff": TTPlanet_Tile_Preprocessor_cufoff
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
| 188 |
+
"TTPlanet_Tile_Preprocessor_GF": "🪐TTPlanet Tile Preprocessor GF",
|
| 189 |
+
"TTPlanet_Tile_Preprocessor_Simple": "🪐TTPlanet Tile Preprocessor Simple",
|
| 190 |
+
"TTPlanet_Tile_Preprocessor_cufoff": "🪐TTPlanet Tile Preprocessor cufoff"
|
| 191 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_class_name": "ControlNetModel",
|
| 3 |
+
"_diffusers_version": "0.27.0.dev0",
|
| 4 |
+
"act_fn": "silu",
|
| 5 |
+
"addition_embed_type": "text_time",
|
| 6 |
+
"addition_embed_type_num_heads": 64,
|
| 7 |
+
"addition_time_embed_dim": 256,
|
| 8 |
+
"attention_head_dim": [
|
| 9 |
+
5,
|
| 10 |
+
10,
|
| 11 |
+
20
|
| 12 |
+
],
|
| 13 |
+
"block_out_channels": [
|
| 14 |
+
320,
|
| 15 |
+
640,
|
| 16 |
+
1280
|
| 17 |
+
],
|
| 18 |
+
"class_embed_type": null,
|
| 19 |
+
"conditioning_channels": 3,
|
| 20 |
+
"conditioning_embedding_out_channels": [
|
| 21 |
+
16,
|
| 22 |
+
32,
|
| 23 |
+
96,
|
| 24 |
+
256
|
| 25 |
+
],
|
| 26 |
+
"controlnet_conditioning_channel_order": "rgb",
|
| 27 |
+
"cross_attention_dim": 2048,
|
| 28 |
+
"down_block_types": [
|
| 29 |
+
"DownBlock2D",
|
| 30 |
+
"CrossAttnDownBlock2D",
|
| 31 |
+
"CrossAttnDownBlock2D"
|
| 32 |
+
],
|
| 33 |
+
"downsample_padding": 1,
|
| 34 |
+
"encoder_hid_dim": null,
|
| 35 |
+
"encoder_hid_dim_type": null,
|
| 36 |
+
"flip_sin_to_cos": true,
|
| 37 |
+
"freq_shift": 0,
|
| 38 |
+
"global_pool_conditions": false,
|
| 39 |
+
"in_channels": 4,
|
| 40 |
+
"layers_per_block": 2,
|
| 41 |
+
"mid_block_scale_factor": 1,
|
| 42 |
+
"mid_block_type": "UNetMidBlock2DCrossAttn",
|
| 43 |
+
"norm_eps": 1e-05,
|
| 44 |
+
"norm_num_groups": 32,
|
| 45 |
+
"num_attention_heads": null,
|
| 46 |
+
"num_class_embeds": null,
|
| 47 |
+
"only_cross_attention": false,
|
| 48 |
+
"projection_class_embeddings_input_dim": 2816,
|
| 49 |
+
"resnet_time_scale_shift": "default",
|
| 50 |
+
"transformer_layers_per_block": [
|
| 51 |
+
1,
|
| 52 |
+
2,
|
| 53 |
+
10
|
| 54 |
+
],
|
| 55 |
+
"upcast_attention": null,
|
| 56 |
+
"use_linear_projection": true
|
| 57 |
+
}
|