souranil3d commited on
Commit
3c27500
1 Parent(s): 74ae3e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -16,11 +16,17 @@ cfg = get_cfg()
16
  cfg.merge_from_file(config_file)
17
  cfg.MODEL.DEVICE="cpu"
18
  cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
19
- cfg.MODEL.WEIGHTS = "checkpoints_model_final_imagenet_40k_synthetic.pth"
20
 
21
  def predict(
22
- img
 
23
  ):
 
 
 
 
 
24
  predictor = DefaultPredictor(cfg)
25
  im = cv2.imread(img.name)
26
  output = predictor(im)
@@ -32,7 +38,7 @@ description = "Demo for Indoor Pet Detection"
32
  examples = [['example.jpg']]
33
 
34
 
35
- gr.Interface(predict, inputs=gr.inputs.Image(type="file"), outputs=gr.outputs.Image(type="pil"),enable_queue=True, title=title,
36
  description=description,
37
  # article=article,
38
  examples=examples).launch()
16
  cfg.merge_from_file(config_file)
17
  cfg.MODEL.DEVICE="cpu"
18
  cfg.MODEL.ROI_HEADS.SCORE_THRESH_TEST = 0.5
19
+ # cfg.MODEL.WEIGHTS = "checkpoints_model_final_imagenet_40k_synthetic.pth"
20
 
21
  def predict(
22
+ img,
23
+ model="40k_synthetic"
24
  ):
25
+ if model=="40k_synthetic":
26
+ weights = "checkpoints_model_final_imagenet_40k_synthetic.pth"
27
+ else:
28
+ weights = "checkpoints_model_final_imagenet_40k_synthetic.pth"
29
+ cfg.MODEL.WEIGHTS=model
30
  predictor = DefaultPredictor(cfg)
31
  im = cv2.imread(img.name)
32
  output = predictor(im)
38
  examples = [['example.jpg']]
39
 
40
 
41
+ gr.Interface(predict, [inputs=gr.inputs.Image(type="file"), gr.inputs.Dropdown(["40k_synthetic", "100k_synthetic"])], outputs=gr.outputs.Image(type="pil"),enable_queue=True, title=title,
42
  description=description,
43
  # article=article,
44
  examples=examples).launch()