加入模型选择

main
wangchunlin 4 years ago
parent eb1eba00df
commit b2e4514486

@ -4,7 +4,7 @@
{% load static %}
<link rel="stylesheet" href="{% static 'layui/css/layui.css' %}" media="all">
<meta charset="UTF-8">
<title>Title</title>
<title>WildFire</title>
<script src="../static/layui/layui.js"></script>
<script src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
@ -17,6 +17,17 @@
<i class="layui-icon">&#xe67c;</i>获取剪切板
</button>
获取剪切板在无https情况下失败直接Ctrl+V即可
<p>
<h2>模型选择</h2>
</p>
<div>
<!-- 下拉框 -->
<select id="model">
<option value="1">小模型</option>
<option value="2">大模型</option>
</select>
</div>
<script>
@ -33,7 +44,8 @@ document.addEventListener("paste", function () {
var val = clipboardData.getData('text');
event.preventDefault();
// 字典 dict
$.getJSON('/dlurl/', {'url':val},function(res){
var model = $('#model option:selected').val();
$.getJSON('/dlurl/', {'url':val, 'model':model},function(res){
if(res.flag == false)
{
alert("图片地址错误。")

@ -33,6 +33,8 @@ def upload(request):
def dlurl(request):
if request.method == 'GET':
url = request.GET["url"] #获取前端上传的文件
m_model=request.GET["model"]
print(m_model)
print(url)
name = url.split(r'/')[-1]
if not (name.endswith(".jpg") or name.endswith(".jpeg") or name.endswith(".png") or name.endswith(".bmp")):
@ -48,8 +50,14 @@ def dlurl(request):
f.close
#返回给前端的图片路径用相对路径,前端用绝对路径反而加载不了图片
img_path_res = '/static/detected/'+fix+name
RR = DL.run(weights=(curPath+"/yolov5/v6m6.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':RR, 'flag': True})
if(int(m_model)==1): #小模型
RR = DL.run(weights=(curPath+"/yolov5/v3s.pt"), source=img_path, project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【小模型】"+RR, 'flag': True})
if(int(m_model)==2): #大模型
RR = DL.run(weights=(curPath+"/yolov5/v6m6.pt"), source=img_path, imgsz=(1280, 1280), project=(curPath+"/static/detected"))
return JsonResponse({'img_name':img_path_res,'code':"【大模型】"+RR, 'flag': True})
def home(request):
return render(request, 'home.html')
Loading…
Cancel
Save