From 33fcde8d6f38827e404b9cc1e87aa7d4d84713b8 Mon Sep 17 00:00:00 2001 From: Hmily <961532186@qq.com> Date: Sat, 6 Jan 2024 14:46:53 +0800 Subject: [PATCH] Update README.md --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1cd4152..5767393 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Here are a few effects: Firstly, you need to download the project code and install the required dependencies ``` +# python 3.10 + git clone https://github.com/ihmily/image-matting.git cd image-matting pip install -r requirements.txt @@ -28,8 +30,52 @@ Finally, you can visit http://127.0.0.1:8000   +## Use API + +Please run it before use API + +File upload + +``` +import requests + +server = "http://127.0.0.1:8000" +image_path = "image.png" +model_name = "universal" # people,universal +files = {"image": (image_path, open(image_path, "rb"))} +data = {"model": model_name} +response = requests.post(server+'/matting', files=files, data=data) +print(response.text) +json_data = response.json() +image_url = json_data['result_image_url'] +mask_url = json_data['mask_image_url'] +print("image_url:", server + image_url) +print("mask_url:", server + mask_url) +``` + +Url upload + +``` +import requests + +server = "http://127.0.0.1:8000" +image_url = "http://your-image-url/demo.png" +data = {"image_url": image_url, "model": "universal"} # people,universal +response = requests.post(server+'/matting/url', json=data) +print(response.text) +json_data = response.json() +image_url = json_data['result_image_url'] +mask_url = json_data['mask_image_url'] +print("image_url:",server+image_url) +print("mask_url:",server+mask_url) +``` + +You can freely choose the method you want to upload from above. + +  + ## References [https://modelscope.cn/models/damo/cv_unet_universal-matting/summary](https://modelscope.cn/models/damo/cv_unet_universal-matting/summary) -[https://modelscope.cn/models/damo/cv_unet_image-matting/summary](https://modelscope.cn/models/damo/cv_unet_image-matting/summary) \ No newline at end of file +[https://modelscope.cn/models/damo/cv_unet_image-matting/summary](https://modelscope.cn/models/damo/cv_unet_image-matting/summary)