qiqiyuan commited on
Commit
0818c70
·
verified ·
1 Parent(s): cb46fe2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -4,6 +4,7 @@ import gradio as gr
4
  from huggingface_hub import snapshot_download
5
  import os
6
 
 
7
  def load_model(repo_id):
8
 
9
  download_dir = snapshot_download(repo_id)
@@ -13,6 +14,7 @@ def load_model(repo_id):
13
  detection_model = YOLO(model_path, task='detect')
14
  return detection_model
15
 
 
16
  def predict(pil_img, conf_thresh, iou_thresh):
17
  source = pil_img
18
  results = detection_model.predict(source, conf=conf_thresh, iou=iou_thresh)
@@ -22,6 +24,7 @@ def predict(pil_img, conf_thresh, iou_thresh):
22
  REPO_ID = "qiqiyuan/glasses_and_mouth"
23
  detection_model = load_model(REPO_ID)
24
 
 
25
  def iface():
26
 
27
  interface = gr.Interface(
@@ -39,5 +42,6 @@ def iface():
39
 
40
  return interface
41
 
42
-
43
- iface.launch(share=True)
 
 
4
  from huggingface_hub import snapshot_download
5
  import os
6
 
7
+ #load model
8
  def load_model(repo_id):
9
 
10
  download_dir = snapshot_download(repo_id)
 
14
  detection_model = YOLO(model_path, task='detect')
15
  return detection_model
16
 
17
+ #object detection for image
18
  def predict(pil_img, conf_thresh, iou_thresh):
19
  source = pil_img
20
  results = detection_model.predict(source, conf=conf_thresh, iou=iou_thresh)
 
24
  REPO_ID = "qiqiyuan/glasses_and_mouth"
25
  detection_model = load_model(REPO_ID)
26
 
27
+ #gradio interface
28
  def iface():
29
 
30
  interface = gr.Interface(
 
42
 
43
  return interface
44
 
45
+ #launch the gradio app
46
+ app_iface = iface()
47
+ app_iface.launch(share=True)