AAAAAAyq commited on
Commit
b3d5599
·
1 Parent(s): f2149ba

Update app

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -56,12 +56,12 @@ def post_process(annotations, image, mask_random_color=True, bbox=None, points=N
56
 
57
  # post_process(results[0].masks, Image.open("../data/cake.png"))
58
 
59
- def predict(inp, input_size):
60
  input_size = int(input_size) # 确保 imgsz 是整数
61
- results = model(inp, device='cpu', retina_masks=True, iou=0.7, conf=0.25, imgsz=input_size)
62
  results = format_results(results[0], 100)
63
  results.sort(key=lambda x: x['area'], reverse=True)
64
- pil_image = post_process(annotations=results, image=inp)
65
  return pil_image
66
 
67
  # inp = 'assets/sa_192.jpg'
@@ -70,7 +70,7 @@ def predict(inp, input_size):
70
  # post_process(annotations=results, image_path=inp)
71
 
72
  demo = gr.Interface(fn=predict,
73
- inputs=[gr.inputs.Image(type='pil'), gr.inputs.Dropdown(choices=[512, 800, 1024])],
74
  outputs=['plot'],
75
  examples=[["assets/sa_8776.jpg", 1024]],
76
  # ["assets/sa_1309.jpg", 1024]],
 
56
 
57
  # post_process(results[0].masks, Image.open("../data/cake.png"))
58
 
59
+ def predict(input, input_size):
60
  input_size = int(input_size) # 确保 imgsz 是整数
61
+ results = model(input, device='cpu', retina_masks=True, iou=0.7, conf=0.25, imgsz=input_size)
62
  results = format_results(results[0], 100)
63
  results.sort(key=lambda x: x['area'], reverse=True)
64
+ pil_image = post_process(annotations=results, image=input)
65
  return pil_image
66
 
67
  # inp = 'assets/sa_192.jpg'
 
70
  # post_process(annotations=results, image_path=inp)
71
 
72
  demo = gr.Interface(fn=predict,
73
+ inputs=[gr.inputs.Image(type='pil'), gr.inputs.Dropdown(choices=[512, 800, 1024], default=1024)],
74
  outputs=['plot'],
75
  examples=[["assets/sa_8776.jpg", 1024]],
76
  # ["assets/sa_1309.jpg", 1024]],