Skip to content

Commit c64d672

Browse files
committed
update readme
add example for enhance image
1 parent 76a87df commit c64d672

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
>
2626
> Additionally, `groundingdino-py` may encounter installation errors, especially in Chinese Windows environments. The solution can be found in the following [issue](https://github.com/IDEA-Research/GroundingDINO/issues/206).
2727
28+
29+
> GenerateMask is same as DescribeImage, It is not process as a task, result will directly return
30+
2831
# Instructions for Using the ImageEnhance Interface
2932
Below are examples of parameters that include the main parameters required for ImageEnhance. The V1 interface adopts a form-like approach similar to ImagePrompt to break down the enhance controller.
3033

README_zh.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
>
2727
> 此外, `groundingdino-py` 可能会遇到安装错误, 特别是在中文 windows 环境中, 解决办法参考: [issues](https://github.com/IDEA-Research/GroundingDINO/issues/206)
2828
29+
> 和 DescribeImage 一样,GenerateMask 不会作为 task 处理而是直接返回结果
30+
2931
# ImageEnhance 接口的使用说明
3032

3133
以下面的参数为例,它包含了 ImageEnhance 所需要的主要参数,V1 接口采用和 ImagePrompt 类似的方式将 enhance 控制器拆分成表单形式:

examples/examples_v1.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,39 @@ def image_prompt(
228228
cn_img2=ImageList.image_prompt_1,
229229
)
230230
print(json.dumps(ip_result))
231+
232+
# ###############################################################
233+
# Image Enhance
234+
# ################################################################
235+
236+
# Image Enhance
237+
238+
import requests
239+
240+
url = "http://localhost:8888/v1/generation/image-enhance"
241+
242+
# Define the file path and other form data
243+
file_path = "./examples/imgs/source_face_man.png"
244+
form_data = {
245+
"enhance_checkbox": True,
246+
"enhance_uov_method": "Disabled",
247+
"enhance_enabled_1": True,
248+
"enhance_mask_dino_prompt_1": "face",
249+
"enhance_enabled_2": True,
250+
"enhance_mask_dino_prompt_2": "eyes",
251+
}
252+
253+
# Open the file and prepare it for the request
254+
with open(file_path, "rb") as f:
255+
image = f.read()
256+
f.close()
257+
258+
# Send the request
259+
response = requests.post(
260+
url,
261+
files={"enhance_input_image": image},
262+
data=form_data,
263+
timeout=180)
264+
265+
# Print the response content
266+
print(response.text)

examples/examples_v2.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,59 @@ def text2image_image_prompt(params: dict) -> dict:
230230

231231
t2i_ip_result = text2image_image_prompt(params=t2i_ip_params)
232232
print(json.dumps(t2i_ip_result))
233+
234+
# ################################################################
235+
# Image Enhance
236+
# ################################################################
237+
238+
# Image Enhance
239+
240+
import requests
241+
import json
242+
243+
url = "http://localhost:8888/v2/generation/image-enhance"
244+
245+
headers = {
246+
"Content-Type": "application/json"
247+
}
248+
249+
data = {
250+
"enhance_input_image": "https://raw.githubusercontent.com/mrhan1993/Fooocus-API/main/examples/imgs/source_face_man.png",
251+
"enhance_checkbox": True,
252+
"enhance_uov_method": "Vary (Strong)",
253+
"enhance_uov_processing_order": "Before First Enhancement",
254+
"enhance_uov_prompt_type": "Original Prompts",
255+
"enhance_ctrlnets": [
256+
{
257+
"enhance_enabled": True,
258+
"enhance_mask_dino_prompt": "face",
259+
"enhance_prompt": "",
260+
"enhance_negative_prompt": "",
261+
"enhance_mask_model": "sam",
262+
"enhance_mask_cloth_category": "full",
263+
"enhance_mask_sam_model": "vit_b",
264+
"enhance_mask_text_threshold": 0.25,
265+
"enhance_mask_box_threshold": 0.3,
266+
"enhance_mask_sam_max_detections": 0,
267+
"enhance_inpaint_disable_initial_latent": False,
268+
"enhance_inpaint_engine": "v2.6",
269+
"enhance_inpaint_strength": 1.0,
270+
"enhance_inpaint_respective_field": 0.618,
271+
"enhance_inpaint_erode_or_dilate": 0.0,
272+
"enhance_mask_invert": False
273+
}
274+
]
275+
}
276+
277+
response = requests.post(
278+
url,
279+
headers=headers,
280+
data=json.dumps(data),
281+
timeout=180)
282+
283+
if response.status_code == 200:
284+
print("Request successful!")
285+
print("Response:", response.json())
286+
else:
287+
print("Request failed with status code:", response.status_code)
288+
print("Response:", response.text)

0 commit comments

Comments
 (0)