Skip to content

Commit

Permalink
升级到v7
Browse files Browse the repository at this point in the history
  • Loading branch information
ILG2021 committed Mar 10, 2023
1 parent 5121f5c commit b8dfefc
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 79 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/client/node_modules/
yolov7.pt
Binary file modified README.md
Binary file not shown.
81 changes: 81 additions & 0 deletions auto-py-to-exe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"version": "auto-py-to-exe-configuration_v1",
"pyinstallerOptions": [
{
"optionDest": "noconfirm",
"value": true
},
{
"optionDest": "filenames",
"value": "D:/Duty/Python/yolo-server/yolo.py"
},
{
"optionDest": "onefile",
"value": false
},
{
"optionDest": "console",
"value": true
},
{
"optionDest": "icon_file",
"value": "D:/Duty/Python/yolo-server/yolo.png"
},
{
"optionDest": "ascii",
"value": false
},
{
"optionDest": "clean_build",
"value": false
},
{
"optionDest": "strip",
"value": false
},
{
"optionDest": "noupx",
"value": false
},
{
"optionDest": "disable_windowed_traceback",
"value": false
},
{
"optionDest": "embed_manifest",
"value": true
},
{
"optionDest": "uac_admin",
"value": false
},
{
"optionDest": "uac_uiaccess",
"value": false
},
{
"optionDest": "win_private_assemblies",
"value": false
},
{
"optionDest": "win_no_prefer_redirects",
"value": false
},
{
"optionDest": "bootloader_ignore_signals",
"value": false
},
{
"optionDest": "argv_emulation",
"value": false
},
{
"optionDest": "datas",
"value": "D:/Duty/Python/yolo-server/venv/Lib/site-packages/yolov7;yolov7/"
}
],
"nonPyinstallerOptions": {
"increaseRecursionLimit": true,
"manualArguments": ""
}
}
1 change: 0 additions & 1 deletion pyinstaller.bat

This file was deleted.

67 changes: 0 additions & 67 deletions requirements.txt

This file was deleted.

50 changes: 50 additions & 0 deletions yolo.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "yolo头像检测"
#define MyAppVersion "1.1"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "https://www.example.com/"
#define MyAppExeName "yolo.exe"

[Setup]
PrivilegesRequired=admin
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{21E63C38-A5A2-42AB-B72A-339A460493AA}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\yolo
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
; Remove the following line to run in administrative install mode (install for all users.)
OutputDir=D:\Duty\Python\yolo-server\output\setup
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";

[Files]
Source: "D:\Duty\Python\yolo-server\output\yolo\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "D:\Duty\Python\yolo-server\output\yolo\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{commonstartup}\My Program"; Filename: "{app}\yolo.exe"
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

20 changes: 9 additions & 11 deletions yolov5.py → yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
"""

import argparse
from PIL import Image
import base64
import io
import torch
import json

import yolov7
from PIL import Image
from flask import Flask, request, jsonify
import base64,json

app = Flask(__name__)
models = {}
yolo_model = None


@app.route('/', methods=["GET"])
Expand All @@ -29,7 +31,7 @@ def persons():
for instance in instances:
encoded_data = instance.split(',')[1]
im = Image.open(io.BytesIO(base64.b64decode(encoded_data)))
ai_results = models['yolov5s'](im, size=320) # reduce size=320 for faster inference
ai_results = yolo_model(im, size=320) # reduce size=320 for faster inference
input_dict = json.loads(ai_results.pandas().xyxy[0].to_json(orient="records"))
output_dict = [x for x in input_dict if x['name'] == 'person']
results.append(len(output_dict))
Expand All @@ -46,19 +48,15 @@ def objects():
for instance in instances:
encoded_data = instance.split(',')[1]
im = Image.open(io.BytesIO(base64.b64decode(encoded_data)))
ai_results = models['yolov5s'](im, size=320) # reduce size=320 for faster inference
ai_results = yolo_model(im, size=320) # reduce size=320 for faster inference
input_dict = json.loads(ai_results.pandas().xyxy[0].to_json(orient="records"))
results.append(input_dict)
return json.dumps(results)

if __name__ == "__main__":
print("对象检测v1.0")
parser = argparse.ArgumentParser(description="Flask API exposing YOLOv5 model")
parser.add_argument("--port", default=1235, type=int, help="port number")
parser.add_argument('--model', nargs='+', default=['yolov5s'], help='model(s) to run, i.e. --model yolov5n yolov5s')
opt = parser.parse_args()

for m in opt.model:
models[m] = torch.hub.load("ultralytics/yolov5", m, force_reload=True, skip_validation=True)

yolo_model = yolov7.load('yolov7.pt')
app.run(host="0.0.0.0", port=opt.port) # debug=True causes Restarting with stat

0 comments on commit b8dfefc

Please sign in to comment.