Uminosachi / sd-webui-inpaint-anything

Inpaint Anything extension performs stable diffusion inpainting on a browser UI using masks from Segment Anything.
Apache License 2.0
1.09k stars 101 forks source link

how is use api? #95

Open rookiexjl opened 1 year ago

rookiexjl commented 1 year ago

how is use api?

Uminosachi commented 1 year ago

The instructions for using the API via Python can be found at the link below:

https://github.com/Uminosachi/sd-webui-inpaint-anything/blob/main/README_DEV.md

rookiexjl commented 1 year ago

Will similar API fastapis be added in the future? 

------------------ 原始邮件 ------------------ 发件人: @.>; 发送时间: 2023年9月18日(星期一) 下午5:04 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [Uminosachi/sd-webui-inpaint-anything] how is use api? (Issue #95)

The instructions for using the API via Python can be found at the link below:

https://github.com/Uminosachi/sd-webui-inpaint-anything/blob/main/README_DEV.md

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Uminosachi commented 1 year ago

At this time, there are no plans in place to develop a web API.

rookiexjl commented 1 year ago

Segments Image Create Mask use many point?

rookiexjl commented 1 year ago

python README_DEV.md

import importlib

import numpy as np from PIL import Image, ImageDraw

inpalib = importlib.import_module("extensions.sd-webui-inpaint-anything.inpalib")

inpalib = importlib.import_module("extensions.sd-webui-inpaint-anything.inpalib") available_sam_ids = inpalib.get_available_sam_ids()

use_sam_id = "C:\D\code\stable-diffusion-webui\extensions\sd-webui-inpaint-anything\models\sam_vit_l_0b3195.pth"

assert use_sam_id in available_sam_ids, f"Invalid SAM ID: {use_sam_id}"

input_image = np.array(Image.open("C:\D\code\stable-diffusion-webui\extensions\sd-webui-inpaint-anything\images\isample_input_image.png"))

sam_masks = inpalib.generate_sam_masks(input_image, use_sam_id, anime_style_chk=False) sam_masks = inpalib.sort_masks_by_area(sam_masks)

seg_color_image = inpalib.create_seg_color_image(input_image, sam_masks)

Image.fromarray(seg_color_image).save("C:\D\code\stable-diffusion-webui\extensions\sd-webui-inpaint-anything\images\seg_color_image.png")

sketch_image = Image.fromarray(np.zeros_like(input_image))

draw = ImageDraw.Draw(sketch_image) draw.point((input_image.shape[1] // 2, input_image.shape[0] // 2), fill=(255, 255, 255))

mask_image = inpalib.create_mask_image(np.array(sketch_image), sam_masks, ignore_black_chk=True)

Image.fromarray(mask_image).save("C:\D\code\stable-diffusion-webui\extensions\sd-webui-inpaint-anything\images\mask_image.png")

无法定位程序箱入点 ?assertSignaturelsCorrect@ OperatorEntry@impl@c10@@QEBAXVCppSi gnature@23@ N@Z 于动态链接库 C: Users xiaoyulanaconda3 envs'stable diffusion python10 Lib'site-packages\torchvision), C.pyd 上

Uminosachi commented 1 year ago

The inpalib in the web UI extension version requires webui.bat to be running to function properly. In contrast, the standalone version of inpalib is more user-friendly.

The README_DEV of the Standalone version: https://github.com/Uminosachi/inpaint-anything/blob/main/README_DEV.md

fu-jianhua commented 11 months ago

https://github.com/Uminosachi/sd-webui-inpaint-anything/blob/main/ia_file_manager.py 1695628304527

Excuse me, where did the modules in the fifth line of this file (from modules import shared) come from ?

Uminosachi commented 11 months ago

Excuse me, where did the modules in the fifth line of this file (from modules import shared) come from ?

That import is loading the shared.py file in the stable-diffusion-webui/modules directory.

Dwinovo commented 7 months ago

Excuse me,I copy the code in https://github.com/Uminosachi/sd-webui-inpaint-anything/blob/main/README_DEV.md,but it did not work. image image

rookiexjl commented 7 months ago

什么事