Chanikan commited on
Commit
755710e
·
verified ·
1 Parent(s): 8da2c8c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -25,10 +25,11 @@ fdic = {
25
  "weight" : "bold"
26
  }
27
 
 
28
  def get_figure(in_pil_img, in_results):
29
- plt.figure(figsize=(16,10))
30
  plt.imshow(in_pil_img)
31
-
32
  ax = plt.gca()
33
 
34
  for prediction in in_results:
@@ -36,13 +37,17 @@ def get_figure(in_pil_img, in_results):
36
 
37
  x, y = prediction['box']['xmin'], prediction['box']['ymin'],
38
  w, h = prediction['box']['xmax'] - prediction['box']['xmin'], prediction['box']['ymax'] - prediction['box']['ymin']
 
39
  ax.add_patch(plt.Rectangle((x, y), w, h, fill=False, color=selected_color, linewidth=3))
40
  ax.text(x, y, f"{prediction['label']}: {round(prediction['score']*100, 1)}%", fontdict=fdic)
41
 
42
  plt.axis("off")
 
43
  return plt.gcf()
44
-
 
45
  def infer(model, in_pil_img):
 
46
  results = None
47
  if model == "detr-resnet-101":
48
  results = detector101(in_pil_img)
@@ -58,6 +63,7 @@ def infer(model, in_pil_img):
58
 
59
  return output_pil_img
60
 
 
61
  with gr.Blocks(title="DETR Object Detection - ClassCat",
62
  css=".gradio-container {background:lightyellow;}"
63
  ) as demo:
@@ -93,5 +99,4 @@ with gr.Blocks(title="DETR Object Detection - ClassCat",
93
 
94
 
95
  #demo.queue()
96
- demo.launch(debug=True)
97
-
 
25
  "weight" : "bold"
26
  }
27
 
28
+
29
  def get_figure(in_pil_img, in_results):
30
+ plt.figure(figsize=(16, 10))
31
  plt.imshow(in_pil_img)
32
+ #pyplot.gcf()
33
  ax = plt.gca()
34
 
35
  for prediction in in_results:
 
37
 
38
  x, y = prediction['box']['xmin'], prediction['box']['ymin'],
39
  w, h = prediction['box']['xmax'] - prediction['box']['xmin'], prediction['box']['ymax'] - prediction['box']['ymin']
40
+
41
  ax.add_patch(plt.Rectangle((x, y), w, h, fill=False, color=selected_color, linewidth=3))
42
  ax.text(x, y, f"{prediction['label']}: {round(prediction['score']*100, 1)}%", fontdict=fdic)
43
 
44
  plt.axis("off")
45
+
46
  return plt.gcf()
47
+
48
+
49
  def infer(model, in_pil_img):
50
+
51
  results = None
52
  if model == "detr-resnet-101":
53
  results = detector101(in_pil_img)
 
63
 
64
  return output_pil_img
65
 
66
+
67
  with gr.Blocks(title="DETR Object Detection - ClassCat",
68
  css=".gradio-container {background:lightyellow;}"
69
  ) as demo:
 
99
 
100
 
101
  #demo.queue()
102
+ demo.launch(debug=True)