forked from PrAYtele/Stable-Texturify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
7,211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
fbx_model_path: "./tmp.obj" | ||
output_folder: './' | ||
# textures: | ||
# back: "path/to/your/texture/back.png" | ||
# front: "path/to/your/texture/front.png" | ||
# left: "path/to/your/texture/left.png" | ||
sd_model_checkpoint: 'darkSushi25D25D_v40.safetensors' | ||
seg_node: | ||
random_color: True | ||
depth_node: | ||
map_value_node_offset: 0.5 | ||
map_value_node_size: 0.7 | ||
camera: | ||
view: ['back','front','left','right'] | ||
distance: 1.5 | ||
side_angle: 80 | ||
resolution: | ||
width: 1600 | ||
height: 1600 | ||
textures: { | ||
back: "./Sres_0.png", | ||
front: "./Sres_1.png", | ||
left: "./Sres_2.png" | ||
# 'right': sides_image | ||
} | ||
inpaint_textures: { | ||
back: "./Sres_0_brinting.png", | ||
front: "./Sres_1_brinting.png", | ||
left: "./Sres_inpainted_1.png", | ||
right: "./Sres_inpainted_0.png" | ||
} | ||
project_order: ['back','front','left','right'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import base64 | ||
import io | ||
import json | ||
import requests | ||
from PIL import Image | ||
|
||
def image_to_base64(image_path): | ||
with Image.open(image_path) as img: | ||
buffer = io.BytesIO() | ||
img.save(buffer, format="PNG") | ||
return base64.b64encode(buffer.getvalue()).decode() | ||
|
||
def base64_to_image(base64_data, output_path): | ||
img_data = base64.b64decode(base64_data) | ||
img = Image.open(io.BytesIO(img_data)) | ||
img.save(output_path, format="PNG") | ||
|
||
|
||
img1 = image_to_base64("resample_0.jpg") | ||
img2 = image_to_base64("resample_1.jpg") | ||
|
||
img_list = [img1,img2] | ||
url = "http://127.0.0.1:7860/sdapi/v1/extra-single-image" | ||
for i,img in enumerate(img_list): | ||
data = { | ||
"resize_mode": 1, | ||
"show_extras_results": False, | ||
"gfpgan_visibility": 0, | ||
"codeformer_visibility": 0, | ||
"codeformer_weight": 0, | ||
# "upscaling_resize": 0,#By how much to upscale the image, only used when resize_mode=0. | ||
"upscaling_resize_w": 6400, | ||
"upscaling_resize_h": 6400, | ||
"upscaling_crop": False, | ||
"upscaler_1": "4x-UltraSharp", | ||
# "upscaler_2": "4x-UltraSharp", | ||
#"extras_upscaler_2_visibility": 0.5, | ||
"upscale_first": False, | ||
"image": img | ||
} | ||
# data = { | ||
# "resize_mode": 0, | ||
# "show_extras_results": False, | ||
# "gfpgan_visibility": 0, | ||
# "codeformer_visibility": 0, | ||
# "codeformer_weight": 0, | ||
# "upscaling_resize": 1, | ||
# "upscaling_resize_w": 4096, | ||
# "upscaling_resize_h": 4096, | ||
# "upscaling_crop": False, | ||
# "upscaler_1": "SwinIR_4x", | ||
# "upscaler_2": "R-ESRGAN 4x+ Anime6B", | ||
# "extras_upscaler_2_visibility": 0.5, | ||
# "upscale_first": False, | ||
# "imageList": [ | ||
# { | ||
# "data": img1, | ||
# "name": "C:\\Users\\y\\code\\ppainter\\restored_image_1.jpg" | ||
# } | ||
# ] | ||
# } | ||
|
||
headers = {"Content-Type": "application/json"} | ||
|
||
response = requests.post(url, data=json.dumps(data), headers=headers) | ||
|
||
if response.status_code == 200: | ||
print("Request was successful") | ||
response_data = response.json() | ||
output_image_path = "Sres_{}.png" | ||
base64_to_image(response_data["image"], output_image_path.format(str(i))) | ||
print(f"Saved output image to {output_image_path.format(str(i))}") | ||
else: | ||
print(f"Request failed with status code {response.status_code}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import base64 | ||
import io | ||
import json | ||
import requests | ||
from PIL import Image | ||
|
||
def image_to_base64(image_path): | ||
with Image.open(image_path) as img: | ||
buffer = io.BytesIO() | ||
img.save(buffer, format="PNG") | ||
return base64.b64encode(buffer.getvalue()).decode() | ||
|
||
def base64_to_image(base64_data, output_path): | ||
img_data = base64.b64decode(base64_data) | ||
img = Image.open(io.BytesIO(img_data)) | ||
img.save(output_path, format="PNG") | ||
|
||
|
||
img1 = image_to_base64("inpainted_0.png") | ||
img2 = image_to_base64("inpainted_1.png") | ||
img_list = [img1,img2] | ||
url = "http://127.0.0.1:7860/sdapi/v1/extra-single-image" | ||
for i,img in enumerate(img_list): | ||
data = { | ||
"resize_mode": 1, | ||
"show_extras_results": False, | ||
"gfpgan_visibility": 0, | ||
"codeformer_visibility": 0, | ||
"codeformer_weight": 0, | ||
# "upscaling_resize": 0,#By how much to upscale the image, only used when resize_mode=0. | ||
"upscaling_resize_w": 6400, | ||
"upscaling_resize_h": 6400, | ||
"upscaling_crop": False, | ||
"upscaler_1": "4x-UltraSharp", | ||
# "upscaler_2": "4x-UltraSharp", | ||
# "extras_upscaler_2_visibility": 0.5, | ||
"upscale_first": False, | ||
"image": img | ||
} | ||
# data = { | ||
# "resize_mode": 0, | ||
# "show_extras_results": False, | ||
# "gfpgan_visibility": 0, | ||
# "codeformer_visibility": 0, | ||
# "codeformer_weight": 0, | ||
# "upscaling_resize": 1, | ||
# "upscaling_resize_w": 4096, | ||
# "upscaling_resize_h": 4096, | ||
# "upscaling_crop": False, | ||
# "upscaler_1": "SwinIR_4x", | ||
# "upscaler_2": "R-ESRGAN 4x+ Anime6B", | ||
# "extras_upscaler_2_visibility": 0.5, | ||
# "upscale_first": False, | ||
# "imageList": [ | ||
# { | ||
# "data": img1, | ||
# "name": "C:\\Users\\y\\code\\ppainter\\restored_image_1.jpg" | ||
# } | ||
# ] | ||
# } | ||
|
||
headers = {"Content-Type": "application/json"} | ||
|
||
response = requests.post(url, data=json.dumps(data), headers=headers) | ||
|
||
if response.status_code == 200: | ||
print("Request was successful") | ||
response_data = response.json() | ||
output_image_path = "Sres_inpainted_{}.png" | ||
base64_to_image(response_data["image"], output_image_path.format(str(i))) | ||
print(f"Saved output image to {output_image_path.format(str(i))}") | ||
else: | ||
print(f"Request failed with status code {response.status_code}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import base64 | ||
import io | ||
import json | ||
import requests | ||
from PIL import Image | ||
import yaml | ||
def image_to_base64(image_path): | ||
with Image.open(image_path) as img: | ||
buffer = io.BytesIO() | ||
img.save(buffer, format="PNG") | ||
return base64.b64encode(buffer.getvalue()).decode() | ||
|
||
def base64_to_image(base64_data, output_path): | ||
img_data = base64.b64decode(base64_data) | ||
img = Image.open(io.BytesIO(img_data)) | ||
img.save(output_path, format="PNG") | ||
|
||
with open("Render_config.yaml", "r") as f: | ||
config = yaml.safe_load(f) | ||
sd_model = config["sd_model_checkpoint"] | ||
img1 = image_to_base64("tex_fusion.png") | ||
bin_uv = image_to_base64("binary_uv.png") | ||
bin_uv_layout = image_to_base64("binary_uv_layout.png") | ||
|
||
img_list = [img1] | ||
url = "http://127.0.0.1:7860/sdapi/v1/img2img" | ||
# model_list = requests.get("http://127.0.0.1:7860/sdapi/v1/sd-models") | ||
# print(model_list.text) | ||
for i,img in enumerate(img_list): | ||
data = { | ||
"init_images": [img], | ||
|
||
'prompt': 'vrass,textured', | ||
'negative_prompt': 'blur,motion blur', | ||
'enable_hr': False, | ||
'denoising_strength': 0.2, | ||
# 'hr_upscaler': 'Latent (bicubic)', | ||
# 'hr_scale': 1.0, | ||
'seed': -1, | ||
'sampler_name': 'Euler a', | ||
'batch_size': 1, | ||
'steps': 20, | ||
#'quick_steps': 20, | ||
'cfg_scale': 7, | ||
'width': 512, | ||
'height': 512, | ||
# 'override_settings': {'CLIP_stop_at_last_layers': 1}, | ||
'override_settings': {'sd_model_checkpoint': 'imageToVroidStudio_12.ckpt'}, | ||
|
||
# 'override_settings_restore_afterwards': 'false', | ||
# 'hr_second_pass_steps': 20, | ||
"alwayson_scripts": { | ||
"controlnet": { | ||
"args": [ | ||
{ | ||
"enabled":True, | ||
# "module":"tile_resample", | ||
"input_image": bin_uv_layout, | ||
"model": "control_v11p_sd15_seg", | ||
"resize_mode": 0, | ||
"processor_res":512, | ||
"weight":1, | ||
# "threshold_a":1 | ||
|
||
}, | ||
{ | ||
"enabled":False, | ||
"input_image": bin_uv, | ||
# "module":'invert', | ||
"model": "control_v11p_sd15s2_lineart_anime", | ||
"resize_mode": 0, | ||
"processor_res":512, | ||
"weight":0.5 | ||
|
||
}, | ||
{ | ||
"enabled":True, | ||
"module":"tile_resample", | ||
"input_image": img, | ||
"model": "control_v11f1e_sd15_tile", | ||
"resize_mode": 0, | ||
"processor_res":2048, | ||
"weight":1, | ||
"threshold_a":1 | ||
} | ||
] | ||
} | ||
} | ||
} | ||
|
||
headers = {"Content-Type": "application/json"} | ||
|
||
response = requests.post(url, data=json.dumps(data), headers=headers) | ||
|
||
if response.status_code == 200: | ||
print("Request was successful") | ||
response_data = response.json() | ||
output_image_path = "tex_remap_{}.png" | ||
base64_to_image(response_data["images"][0], output_image_path.format(str(i))) | ||
print(f"Saved output image to {output_image_path.format(str(i))}") | ||
else: | ||
print(f"Request failed with status code {response.status_code}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import base64 | ||
import io | ||
import json | ||
import requests | ||
from PIL import Image | ||
|
||
def image_to_base64(image_path): | ||
with Image.open(image_path) as img: | ||
buffer = io.BytesIO() | ||
img.save(buffer, format="PNG") | ||
return base64.b64encode(buffer.getvalue()).decode() | ||
|
||
def base64_to_image(base64_data, output_path): | ||
img_data = base64.b64decode(base64_data) | ||
img = Image.open(io.BytesIO(img_data)) | ||
img.save(output_path, format="PNG") | ||
|
||
|
||
img1 = image_to_base64("tex_tile_0.png") | ||
|
||
img_list = [img1] | ||
url = "http://127.0.0.1:7860/sdapi/v1/extra-single-image" | ||
for i,img in enumerate(img_list): | ||
data = { | ||
"resize_mode": 1, | ||
"show_extras_results": False, | ||
"gfpgan_visibility": 0, | ||
"codeformer_visibility": 0, | ||
"codeformer_weight": 0, | ||
# "upscaling_resize": 0,#By how much to upscale the image, only used when resize_mode=0. | ||
"upscaling_resize_w": 4096, | ||
"upscaling_resize_h": 4096, | ||
"upscaling_crop": False, | ||
"upscaler_1": "4x-UltraSharp", | ||
# "upscaler_2": "4x-UltraSharp", | ||
# "extras_upscaler_2_visibility": 0.5, | ||
"upscale_first": False, | ||
"image": img | ||
} | ||
# data = { | ||
# "resize_mode": 0, | ||
# "show_extras_results": False, | ||
# "gfpgan_visibility": 0, | ||
# "codeformer_visibility": 0, | ||
# "codeformer_weight": 0, | ||
# "upscaling_resize": 1, | ||
# "upscaling_resize_w": 4096, | ||
# "upscaling_resize_h": 4096, | ||
# "upscaling_crop": False, | ||
# "upscaler_1": "SwinIR_4x", | ||
# "upscaler_2": "R-ESRGAN 4x+ Anime6B", | ||
# "extras_upscaler_2_visibility": 0.5, | ||
# "upscale_first": False, | ||
# "imageList": [ | ||
# { | ||
# "data": img1, | ||
# "name": "C:\\Users\\y\\code\\ppainter\\restored_image_1.jpg" | ||
# } | ||
# ] | ||
# } | ||
|
||
headers = {"Content-Type": "application/json"} | ||
|
||
response = requests.post(url, data=json.dumps(data), headers=headers) | ||
|
||
if response.status_code == 200: | ||
print("Request was successful") | ||
response_data = response.json() | ||
output_image_path = "Tex_sres_{}.png" | ||
base64_to_image(response_data["image"], output_image_path.format(str(i))) | ||
print(f"Saved output image to {output_image_path.format(str(i))}") | ||
else: | ||
print(f"Request failed with status code {response.status_code}") |
Oops, something went wrong.