Zengyf-CVer commited on
Commit
6043033
1 Parent(s): ed65b4c

app update

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -1,6 +1,6 @@
1
- # Gradio YOLOv8 Det v0.2
2
  # 创建人:曾逸夫
3
- # 创建时间:2023-01-20
4
 
5
  import argparse
6
  import csv
@@ -45,7 +45,7 @@ from util.fonts_opt import is_fonts
45
  ROOT_PATH = sys.path[0] # 根目录
46
 
47
  # Gradio YOLOv8 Det版本
48
- GYD_VERSION = "Gradio YOLOv8 Det v0.2"
49
 
50
  # 文件后缀
51
  suffix_list = [".csv", ".yaml"]
@@ -58,7 +58,7 @@ obj_style = ["小目标", "中目标", "大目标"]
58
 
59
 
60
  def parse_args(known=False):
61
- parser = argparse.ArgumentParser(description="Gradio YOLOv8 Det v0.2")
62
  parser.add_argument("--model_type", "-mt", default="online", type=str, help="model type")
63
  parser.add_argument("--source", "-src", default="upload", type=str, help="image input source")
64
  parser.add_argument("--source_video", "-src_v", default="upload", type=str, help="video input source")
@@ -236,12 +236,9 @@ def polygon_drawing(img_mask, canvas, color_seg):
236
  # 输出分割结果
237
  def seg_output(img_path, seg_mask_list, color_list, cls_list):
238
  img = cv2.imread(img_path)
239
- w, h = img.shape[1], img.shape[0]
240
- img = cv2.cvtColor(img, cv2.COLOR_BGR2BGRA)
241
 
242
  w, h = img.shape[1], img.shape[0]
243
- canvas = np.zeros((h, w, 3), dtype=np.uint8)
244
- canvas = cv2.cvtColor(canvas, cv2.COLOR_BGR2BGRA)
245
 
246
  # 获取分割坐标
247
  for seg_mask, cls_index in zip(seg_mask_list, cls_list):
@@ -249,9 +246,9 @@ def seg_output(img_path, seg_mask_list, color_list, cls_list):
249
  for i in range(len(seg_mask)):
250
  img_mask.append([seg_mask[i][0] * w, seg_mask[i][1] * h])
251
 
252
- polygon_drawing(img_mask, canvas, color_list[int(cls_index)]) # 绘制分割图形
253
 
254
- img_mask_merge = cv2.add(img, canvas) # 合并图像
255
 
256
  return img_mask_merge
257
 
 
1
+ # Gradio YOLOv8 Det v0.2.2
2
  # 创建人:曾逸夫
3
+ # 创建时间:2023-01-23
4
 
5
  import argparse
6
  import csv
 
45
  ROOT_PATH = sys.path[0] # 根目录
46
 
47
  # Gradio YOLOv8 Det版本
48
+ GYD_VERSION = "Gradio YOLOv8 Det v0.2.2"
49
 
50
  # 文件后缀
51
  suffix_list = [".csv", ".yaml"]
 
58
 
59
 
60
  def parse_args(known=False):
61
+ parser = argparse.ArgumentParser(description="Gradio YOLOv8 Det v0.2.2")
62
  parser.add_argument("--model_type", "-mt", default="online", type=str, help="model type")
63
  parser.add_argument("--source", "-src", default="upload", type=str, help="image input source")
64
  parser.add_argument("--source_video", "-src_v", default="upload", type=str, help="video input source")
 
236
  # 输出分割结果
237
  def seg_output(img_path, seg_mask_list, color_list, cls_list):
238
  img = cv2.imread(img_path)
239
+ img_c = img.copy()
 
240
 
241
  w, h = img.shape[1], img.shape[0]
 
 
242
 
243
  # 获取分割坐标
244
  for seg_mask, cls_index in zip(seg_mask_list, cls_list):
 
246
  for i in range(len(seg_mask)):
247
  img_mask.append([seg_mask[i][0] * w, seg_mask[i][1] * h])
248
 
249
+ polygon_drawing(img_mask, img_c, color_list[int(cls_index)]) # 绘制分割图形
250
 
251
+ img_mask_merge = cv2.addWeighted(img, 0.3, img_c, 0.7, 0) # 合并图像
252
 
253
  return img_mask_merge
254