Zengyf-CVer commited on
Commit
a33f57b
1 Parent(s): 2eac0e5

app update

Browse files
Files changed (2) hide show
  1. app.py +10 -20
  2. requirements.txt +1 -1
app.py CHANGED
@@ -34,6 +34,8 @@ SimSun = font_manager.FontProperties(fname=SimSun_path, size=12)
34
  # 新罗马字体
35
  TimesNesRoman = font_manager.FontProperties(fname=TimesNesRoman_path, size=12)
36
 
 
 
37
  import yaml
38
  from PIL import Image, ImageDraw, ImageFont
39
 
@@ -161,26 +163,14 @@ def check_online():
161
  def model_loading(img_path, conf, iou, infer_size, yolo_model="yolov8n.pt"):
162
  model = YOLO(yolo_model)
163
 
164
- results = model(img_path, imgsz=infer_size, conf=conf, iou=iou)
165
- return results[0].tolist()
166
-
167
-
168
- # 检测信息
169
- def export_json(results, img_size):
170
-
171
- return [[{
172
- "ID": i,
173
- "CLASS": int(result[i][5]),
174
- "CLASS_NAME": model_cls_name_cp[int(result[i][5])],
175
- "BOUNDING_BOX": {
176
- "XMIN": round(result[i][:4].tolist()[0], 6),
177
- "YMIN": round(result[i][:4].tolist()[1], 6),
178
- "XMAX": round(result[i][:4].tolist()[2], 6),
179
- "YMAX": round(result[i][:4].tolist()[3], 6),},
180
- "CONF": round(float(result[i][4]), 2),
181
- "FPS": round(1000 / float(results.t[1]), 2),
182
- "IMG_WIDTH": img_size[0],
183
- "IMG_HEIGHT": img_size[1],} for i in range(len(result))] for result in results.xyxyn]
184
 
185
 
186
  # 标签和边界框颜色设置
 
34
  # 新罗马字体
35
  TimesNesRoman = font_manager.FontProperties(fname=TimesNesRoman_path, size=12)
36
 
37
+ from copy import deepcopy
38
+
39
  import yaml
40
  from PIL import Image, ImageDraw, ImageFont
41
 
 
163
  def model_loading(img_path, conf, iou, infer_size, yolo_model="yolov8n.pt"):
164
  model = YOLO(yolo_model)
165
 
166
+ results = model.predict(source=img_path, imgsz=infer_size, conf=conf, iou=iou, return_outputs=True)
167
+ det = []
168
+ for i in results:
169
+ det.append(deepcopy(i))
170
+
171
+ det_list = det[0]["det"].tolist()
172
+
173
+ return det_list
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
 
176
  # 标签和边界框颜色设置
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
- ultralytics==8.0.3
2
  opencv-python
3
  matplotlib
4
  numpy
 
1
+ ultralytics
2
  opencv-python
3
  matplotlib
4
  numpy