diff --git a/BaiHu/Backup/Banner/qinglv_加文字.png b/BaiHu/Backup/Banner/qinglv_加文字.png new file mode 100644 index 00000000..3e013605 Binary files /dev/null and b/BaiHu/Backup/Banner/qinglv_加文字.png differ diff --git a/BaiHu/Backup/Banner/qinglv_小图.png b/BaiHu/Backup/Banner/qinglv_小图.png index 67e39d57..0678689c 100644 Binary files a/BaiHu/Backup/Banner/qinglv_小图.png and b/BaiHu/Backup/Banner/qinglv_小图.png differ diff --git a/BaiHu/Test/WD14.py b/BaiHu/Test/WD14.py new file mode 100644 index 00000000..5bbaa0e3 --- /dev/null +++ b/BaiHu/Test/WD14.py @@ -0,0 +1,49 @@ +import requests +import base64 +from PIL import Image + +url = 'http://192.168.1.21:7860/tagger/v1/interrogate' +image_path = r'D:\KeCheng\BaiHu\Backup\mote2.png' + +# 反推模型 +model = 'wd14-vit-v2-git' # 'wd14-convnext' +# 阀值 +threshold = 0.35 + +# 确认照片为上传照片 +image = Image.open(image_path) +# 将图片转换为Base64字符串 +with open(image_path, 'rb') as file: + image_data = file.read() + base64_image = base64.b64encode(image_data).decode('utf-8') + +image.close() + +# 构建请求体的JSON数据 +data = { + "image": base64_image, + "model": model, + "threshold": threshold +} + +# 发送POST请求 +response = requests.post(url, json=data) + +# 检查响应状态码 +if response.status_code == 200: + json_data = response.json() + # 处理返回的JSON数据 + caption_dict = json_data['caption'] + sorted_items = sorted(caption_dict.items(), key=lambda x: x[1], reverse=True) + # output = '\n'.join([f'{k}: {v}, {int(v * 100)}%' for k, v in sorted_items]) + # output = ','.join([f'{k.replace("_"," ")}' for k, v in sorted_items]) + + output = '' + for k, v in sorted_items: + if v > threshold: + output = output + "," + k.replace("_", " ") + output = output[1:] + print(output) +else: + print('Error:', response.status_code) + print('Response body:', response.text)