YONG627 commited on
Commit
9ab4d36
·
1 Parent(s): b6d6964

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -11,9 +11,6 @@ base_conf, base_iou = 0.15, 0.5
11
  def load_model(model_path):
12
  model = torch.hub.load("yolov5-code-main/", "custom", path=model_path, source="local")
13
  return model
14
- def add_text():
15
- text = "多病变模型可识别的病变类型为:barrett(巴雷特食道),esophageal-cancer(食道癌),cancer(胃癌),esophageal papilloma(食道乳头状瘤),gastric polyp(胃息肉),mycotic esophagitis(真菌性食道炎),GIM(胃肠上皮化生),esophageal varices(食道静脉曲张),Reflux esophagitis(反流性食道炎)"
16
- return text
17
 
18
 
19
 
@@ -23,12 +20,21 @@ def det_image(img, model_path, conf_最小置信度, iou_最大置信度):
23
  model.iou = iou_最大置信度
24
 
25
  return model(img).render()[0]
 
 
 
 
 
 
 
 
 
26
 
27
  iface = gr.Interface(inputs=["image", gr.inputs.Dropdown(model_paths, label="选择模型"), gr.Slider(minimum=0, maximum=1, value=base_conf), gr.Slider(minimum=0, maximum=1, value=base_iou)],
28
  outputs=["image"],
29
  fn=det_image,
30
  title=title,
31
- description="<img src='https://img.zcool.cn/community/01b04956170efa32f875313d664d44.gif' />",
32
  article="<img src='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201505%2F24%2F20150524222415_hwTnY.thumb.700_0.gif&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1697462434&t=be8ccd6bf414a078c71ef063f3da378a' width='100' height='100'/>" + "<p style='text-align:center; font-size:16px; color:#333; margin-top:10px;'>" + add_text() + "</p>",
33
  live=True,
34
  examples=[["CS/GIM321.jpg", "多病变识别.pt", base_conf, base_iou], ["CS/barrett278.png", "多病变识别.pt", 0.3, base_iou], ["CS/RERD65.jpg", "多病变识别.pt", base_conf, base_iou],["CS/400.jpg", "胃部息肉识别.pt", base_conf, base_iou],["CS/bus.jpg", "YOLOV5官方模型.pt", base_conf, base_iou]]
 
11
  def load_model(model_path):
12
  model = torch.hub.load("yolov5-code-main/", "custom", path=model_path, source="local")
13
  return model
 
 
 
14
 
15
 
16
 
 
20
  model.iou = iou_最大置信度
21
 
22
  return model(img).render()[0]
23
+ def add_text():
24
+ main_text = "多病变模型可识别的病变类型为:barrett(巴雷特食道),esophageal-cancer(食道癌),cancer(胃癌),esophageal papilloma(食道乳头状瘤),gastric polyp(胃息肉),mycotic esophagitis(真菌性食道炎),GIM(胃肠上皮化生),esophageal varices(食道静脉曲张),Reflux esophagitis(反流性食道炎)"
25
+ extra_text = ""
26
+ return main_text + "<br>" + extra_text
27
+
28
+ def add1_text():
29
+ main1_text = ""
30
+ extra1_text = "该平台基于gradio免费服务器构建,其处理速度受公共服务器影响可能略慢,望理解!"
31
+ return main1_text + "<br>" + extra1_text
32
 
33
  iface = gr.Interface(inputs=["image", gr.inputs.Dropdown(model_paths, label="选择模型"), gr.Slider(minimum=0, maximum=1, value=base_conf), gr.Slider(minimum=0, maximum=1, value=base_iou)],
34
  outputs=["image"],
35
  fn=det_image,
36
  title=title,
37
+ description="<img src='https://img.zcool.cn/community/01b04956170efa32f875313d664d44.gif' />" + "<p style='text-align:center; font-size:16px; color:#333; margin-top:10px;'>" + add1_text() + "</p>",
38
  article="<img src='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201505%2F24%2F20150524222415_hwTnY.thumb.700_0.gif&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1697462434&t=be8ccd6bf414a078c71ef063f3da378a' width='100' height='100'/>" + "<p style='text-align:center; font-size:16px; color:#333; margin-top:10px;'>" + add_text() + "</p>",
39
  live=True,
40
  examples=[["CS/GIM321.jpg", "多病变识别.pt", base_conf, base_iou], ["CS/barrett278.png", "多病变识别.pt", 0.3, base_iou], ["CS/RERD65.jpg", "多病变识别.pt", base_conf, base_iou],["CS/400.jpg", "胃部息肉识别.pt", base_conf, base_iou],["CS/bus.jpg", "YOLOV5官方模型.pt", base_conf, base_iou]]