mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
flexible processour output type
This commit is contained in:
@@ -38,10 +38,8 @@ class MarigoldDetector:
|
||||
batch_size=1,
|
||||
show_progress_bar=True,
|
||||
)
|
||||
depth_map = res.depth_np
|
||||
depth_colored = res.depth_colored
|
||||
|
||||
depth_map = res.depth_colored if color_map != 'None' else res.depth_np
|
||||
if output_type == "pil":
|
||||
depth_map = Image.fromarray(depth_map)
|
||||
|
||||
return depth_colored if color_map != 'None' else depth_map
|
||||
return Image.fromarray(depth_map)
|
||||
else:
|
||||
return depth_map
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
from modules.shared import log
|
||||
from modules.errors import display
|
||||
@@ -219,11 +220,15 @@ class Processor():
|
||||
t0 = time.time()
|
||||
kwargs = config.get(self.processor_id, {}).get('params', None)
|
||||
if self.resize:
|
||||
image_resized = image_input.resize((512, 512))
|
||||
image_resized = image_input.resize((512, 512), Image.Resampling.LANCZOS)
|
||||
else:
|
||||
image_resized = image_input
|
||||
with devices.inference_context():
|
||||
image_process = self.model(image_resized, **kwargs)
|
||||
if isinstance(image_process, np.ndarray):
|
||||
if np.max(image_process) < 2:
|
||||
image_process = (255.0 * image_process).astype(np.uint8)
|
||||
image_process = Image.fromarray(image_process, 'L')
|
||||
if self.resize and image_process.size != image_input.size:
|
||||
image_process = image_process.resize(image_input.size, Image.Resampling.LANCZOS)
|
||||
t1 = time.time()
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@ def img2img(id_task: str, mode: int,
|
||||
image = inpaint_color_sketch
|
||||
orig = inpaint_color_sketch_orig or inpaint_color_sketch
|
||||
pred = np.any(np.array(image) != np.array(orig), axis=-1)
|
||||
mask = Image.fromarray(pred.astype(np.uint8) * 255, "L")
|
||||
mask = Image.fromarray((255.0 * pred).astype(np.uint8), "L")
|
||||
mask = ImageEnhance.Brightness(mask).enhance(mask_alpha)
|
||||
blur = ImageFilter.GaussianBlur(mask_blur)
|
||||
image = Image.composite(image.filter(blur), orig, mask.filter(blur))
|
||||
|
||||
@@ -416,7 +416,7 @@ def create_ui(_blocks: gr.Blocks=None):
|
||||
with gr.Tab('IP Adapter') as _tab_ipadapter:
|
||||
with gr.Row():
|
||||
with gr.Column():
|
||||
gr.HTML('<a href="https://github.com/TencentARC/T2I-Adapter">T2I-Adapter</a>')
|
||||
gr.HTML('<a href="https://github.com/tencent-ailab/IP-Adapter">IP-Adapter</a>')
|
||||
ip_adapter = gr.Dropdown(label='Adapter', choices=ipadapter.ADAPTERS, value='none')
|
||||
ip_scale = gr.Slider(label='Scale', minimum=0.0, maximum=1.0, step=0.01, value=0.5)
|
||||
with gr.Column():
|
||||
|
||||
Reference in New Issue
Block a user