tracker
parent
27b6575ec9
commit
e1c0e16619
2
app.py
2
app.py
|
@ -102,7 +102,7 @@ def worker(id,source,region=None,stream=False):
|
|||
print("Error opening video stream....")
|
||||
break
|
||||
continue
|
||||
result = model.track(frame,show=False,stream=False,persist=True,device=int(id)%4)
|
||||
result = model.track(frame,show=False,stream=False,persist=True,device=int(id)%4,tracker='botsort.yaml')
|
||||
use += " track:"+str((time.time()*1000) - bgn)
|
||||
del(ret)
|
||||
del(frame)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
# Default YOLO tracker settings for BoT-SORT tracker https://github.com/NirAharon/BoT-SORT
|
||||
|
||||
tracker_type: botsort # tracker type, ['botsort', 'bytetrack']
|
||||
track_high_thresh: 0.5 # threshold for the first association
|
||||
track_low_thresh: 0.1 # threshold for the second association
|
||||
new_track_thresh: 0.6 # threshold for init new track if the detection does not match any tracks
|
||||
track_buffer: 30 # buffer to calculate the time when to remove tracks
|
||||
match_thresh: 0.8 # threshold for matching tracks
|
||||
# min_box_area: 10 # threshold for min box areas(for tracker evaluation, not used for now)
|
||||
# mot20: False # for tracker evaluation(not used for now)
|
||||
|
||||
# BoT-SORT settings
|
||||
gmc_method: sparseOptFlow # method of global motion compensation
|
||||
# ReID model related thresh (not supported yet)
|
||||
proximity_thresh: 0.5
|
||||
appearance_thresh: 0.25
|
||||
with_reid: False
|
106
show.py
106
show.py
|
@ -2,6 +2,7 @@ import cv2
|
|||
import json
|
||||
import time
|
||||
import logging
|
||||
import threading
|
||||
import requests
|
||||
import supervision as sv
|
||||
|
||||
|
@ -28,32 +29,48 @@ import re
|
|||
@app.route('/mj',methods=['POST'])
|
||||
def mj():
|
||||
print(request.json)
|
||||
|
||||
if request.json["progress"] == "100%":
|
||||
print(request.json["imageUrl"])
|
||||
sendmsg(request.json["imageUrl"])
|
||||
download_image(request.json["imageUrl"], "MJ", request.json["state"])
|
||||
return 'ok'
|
||||
|
||||
@app.route('/cq',methods=['POST'])
|
||||
def cq():
|
||||
# print(request.json)
|
||||
print(request.json)
|
||||
if request.json["post_type"] != "message":
|
||||
return 'ok'
|
||||
if request.json["message_type"] != "group":
|
||||
return 'ok'
|
||||
if request.json["group_id"] != "116277572":
|
||||
if request.json["group_id"] != 116277572:
|
||||
return 'ok'
|
||||
print(request.json['raw_message'])
|
||||
# if request.json["user_id"] != 2132960:
|
||||
# return 'ok'
|
||||
|
||||
thread = threading.Thread(target=handle, args=(request.json,))
|
||||
thread.start()
|
||||
return "ok"
|
||||
|
||||
def handle(data):
|
||||
print(data['raw_message'])
|
||||
|
||||
# 正则表达式来匹配URL
|
||||
url_pattern = re.compile(r'url=(.*?)\]')
|
||||
|
||||
# 使用findall来找到所有的URL
|
||||
urls = re.findall(url_pattern, request.json['raw_message'])
|
||||
urls = re.findall(url_pattern, data['raw_message'])
|
||||
|
||||
result = re.sub(r'\[.*?\]', '', data['raw_message'])
|
||||
result = result.replace('\r\n', '')
|
||||
|
||||
name = data["sender"]["card"] or data["sender"]["nickname"]
|
||||
|
||||
base64Array = []
|
||||
# 输出找到的URL
|
||||
for url in urls:
|
||||
print(url)
|
||||
|
||||
|
||||
download_image(url, "QQ", name)
|
||||
# 从URL下载图片
|
||||
response = requests.get(url)
|
||||
response.raise_for_status() # 如果请求失败,此处将引发异常
|
||||
|
@ -70,19 +87,70 @@ def cq():
|
|||
|
||||
if len(base64Array) == 0:
|
||||
return 'ok'
|
||||
prompt = 'game assets,game ui,animal,flower,plant,forest,cute,baby,magical,spirit,fairy,elf,glowing light,anime style,seeming very happy,from above,ultra detailed,soft,on white background'
|
||||
if result != '':
|
||||
prompt = result
|
||||
# 示例调用
|
||||
params = {
|
||||
'base64Array':base64Array,
|
||||
'notifyHook': 'http://hk.luanhailiang.cn:5000/mj',
|
||||
'prompt': 'game assets, game ui, animal, plant, cute, soft, baby, magical, forest, spirit, fairy',
|
||||
'state': ''
|
||||
'prompt': prompt,
|
||||
'state': name
|
||||
}
|
||||
|
||||
response = imagine(params)
|
||||
print(response.json())
|
||||
time.sleep(3)
|
||||
params['prompt'] = prompt + " --iw 2 --niji 5"
|
||||
params['state'] = name+"_niji"
|
||||
response = imagine(params)
|
||||
print(response.json())
|
||||
time.sleep(3)
|
||||
params['prompt'] = prompt + " --iw 2 --style raw"
|
||||
params['state'] = name+"_raw"
|
||||
response = imagine(params)
|
||||
print(response.json())
|
||||
|
||||
return 'ok'
|
||||
|
||||
def download_image(url, t, name):
|
||||
"""
|
||||
从指定URL下载图片并保存到本地文件。
|
||||
|
||||
:param url: 图片的URL。
|
||||
:param local_filename: 要保存图片的本地文件名。
|
||||
"""
|
||||
|
||||
local_filename = f"y:\美术\参考收集\{t}\{datetime.now().strftime('%Y%m%d%H%M%S')}_{name}"
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200: # HTTP状态码200表示请求成功
|
||||
# 获取Content-Type响应头
|
||||
content_type = response.headers['Content-Type']
|
||||
# 判断图片格式
|
||||
ext = ""
|
||||
if 'jpeg' in content_type or 'jpg' in content_type:
|
||||
ext = '.jpg'
|
||||
print('The image is in JPEG format.')
|
||||
elif 'png' in content_type:
|
||||
ext = '.png'
|
||||
print('The image is in PNG format.')
|
||||
elif 'gif' in content_type:
|
||||
ext = '.gif'
|
||||
print('The image is in GIF format.')
|
||||
elif 'webp' in content_type:
|
||||
ext = '.webp'
|
||||
print('The image is in WEBP format.')
|
||||
else:
|
||||
ext = '.png'
|
||||
print(f'Unknown image format: {content_type}')
|
||||
local_filename += ext
|
||||
with open(local_filename, 'wb') as f:
|
||||
f.write(response.content)
|
||||
print(f"Image successfully downloaded to {local_filename}")
|
||||
else:
|
||||
print(f"Error downloading image, HTTP status code: {response.status_code}")
|
||||
|
||||
|
||||
import base64
|
||||
import requests
|
||||
|
||||
|
@ -108,6 +176,24 @@ def imagine(params):
|
|||
|
||||
return response
|
||||
|
||||
|
||||
def sendmsg(url):
|
||||
# 设置 go-cqhttp 服务的 URL 和端口
|
||||
api_url = 'http://localhost:5700/send_msg'
|
||||
|
||||
# 设置要发送的消息参数
|
||||
data = {
|
||||
'group_id': 5464741, # 接收消息的用户的 QQ 号
|
||||
'message_type': 'group', # 消息类型
|
||||
'message': f'[CQ:image,file={url}]' # 消息内容,使用 CQ码 格式
|
||||
}
|
||||
|
||||
# 发送 POST 请求到 go-cqhttp 服务
|
||||
response = requests.post(api_url, data=data)
|
||||
|
||||
# 输出响应
|
||||
print(response.json())
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
# # 这是包含URL的示例文本
|
||||
|
@ -151,5 +237,9 @@ if __name__ == '__main__':
|
|||
# response = imagine(params)
|
||||
# print(response.json())
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
app.logger.setLevel(logging.ERROR)
|
||||
app.run("0.0.0.0",port=8000,threaded=True)
|
||||
|
|
Loading…
Reference in New Issue