freinold commited on
Commit
d09e0d9
·
1 Parent(s): 07f158a

New Visualisation of Bounding Boxes of 1st passtrough; upgraded gradio.

Browse files
Files changed (4) hide show
  1. .gitignore +2 -1
  2. README.md +1 -1
  3. app.py +11 -7
  4. requirements.txt +2 -1
.gitignore CHANGED
@@ -160,4 +160,5 @@ cython_debug/
160
  #.idea/
161
 
162
  # Custom
163
- flagged/
 
 
160
  #.idea/
161
 
162
  # Custom
163
+ flagged/
164
+ anon.jpg
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 🕶
4
  colorFrom: gray
5
  colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 4.4.1
8
  app_file: app.py
9
  pinned: false
10
  license: agpl-3.0
 
4
  colorFrom: gray
5
  colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 4.31.5
8
  app_file: app.py
9
  pinned: false
10
  license: agpl-3.0
app.py CHANGED
@@ -46,23 +46,27 @@ def detect(image):
46
  vehicle_mask = Image.new(mode="L", size=image.size, color=255)
47
  vehicle_draw = ImageDraw.Draw(vehicle_mask)
48
  for vehicle_box in vehicle_boxes:
49
- vehicle_draw.rectangle(vehicle_box.tolist(), outline = 0, width=5)
50
-
51
 
 
 
 
 
52
 
53
  #TODO: move combination to caller function
54
  combined_mask = Image.fromarray(np.minimum.reduce([np.array(m) for m in [people_mask, lp_mask]]))
55
- return combined_mask, people_mask, lp_mask, vehicle_mask
56
 
57
 
58
  def test_comb(image):
59
- mask, people_mask, lp_mask, vm = detect(image)
60
  blurred = image.filter(ImageFilter.GaussianBlur(30))
61
  anonymized = Image.composite(image, blurred, mask)
62
  ## TODO: Tempfile statt einem generischen File
63
  anonymized.save("anon.JPG")
64
- annotation_list = [(1 - np.asarray(people_mask) / 255, "Person"), (1 - np.asarray(vm) / 255, "Fahrzeug"), (1 - np.asarray(lp_mask) / 255, "Kennzeichen")]
65
- return "anon.JPG", (image, annotation_list)
 
66
 
67
 
68
  css = """
@@ -87,7 +91,7 @@ Ein Prototyp des it@M InnovationLab ([email protected])
87
  demo = gr.Interface(
88
  fn=test_comb,
89
  inputs=gr.Image(type="pil", label="Zu anonymisierendes Bild"),
90
- outputs=[gr.Image(label="Anonymisiertes Bild"), gr.AnnotatedImage(label="Erkannte Regionen")],
91
  title="Bild auswählen / hochladen",
92
  allow_flagging="never",
93
  examples="examples",
 
46
  vehicle_mask = Image.new(mode="L", size=image.size, color=255)
47
  vehicle_draw = ImageDraw.Draw(vehicle_mask)
48
  for vehicle_box in vehicle_boxes:
49
+ vehicle_draw.rectangle(vehicle_box.tolist(), fill=0)
 
50
 
51
+ person_box_mask = Image.new(mode="L", size=image.size, color=255)
52
+ person_box_draw = ImageDraw.Draw(person_box_mask)
53
+ for person_box in seg_boxes[person_indices][:, :4]:
54
+ person_box_draw.rectangle(person_box.tolist(), fill=0)
55
 
56
  #TODO: move combination to caller function
57
  combined_mask = Image.fromarray(np.minimum.reduce([np.array(m) for m in [people_mask, lp_mask]]))
58
+ return combined_mask, people_mask, lp_mask, vehicle_mask, person_box_mask
59
 
60
 
61
  def test_comb(image):
62
+ mask, people_mask, lp_mask, vm, pbm = detect(image)
63
  blurred = image.filter(ImageFilter.GaussianBlur(30))
64
  anonymized = Image.composite(image, blurred, mask)
65
  ## TODO: Tempfile statt einem generischen File
66
  anonymized.save("anon.JPG")
67
+ box_list = [(1 - np.asarray(pbm) / 255, "Person (Rahmen)"), (1 - np.asarray(vm) / 255, "Fahrzeug")]
68
+ anon_list = [(1 - np.asarray(people_mask) / 255, "Person (Umriss)"), (1 - np.asarray(lp_mask) / 255, "Kennzeichen")]
69
+ return "anon.JPG", (image, box_list), (image, anon_list)
70
 
71
 
72
  css = """
 
91
  demo = gr.Interface(
92
  fn=test_comb,
93
  inputs=gr.Image(type="pil", label="Zu anonymisierendes Bild"),
94
+ outputs=[gr.Image(label="Anonymisiertes Bild"), gr.AnnotatedImage(label="Detektierte Umrisse"), gr.AnnotatedImage(label="Erkannte Objekte")],
95
  title="Bild auswählen / hochladen",
96
  allow_flagging="never",
97
  examples="examples",
requirements.txt CHANGED
@@ -3,4 +3,5 @@ ultralytics
3
  Pillow
4
  numpy
5
  torch
6
- torchvision
 
 
3
  Pillow
4
  numpy
5
  torch
6
+ torchvision
7
+ dill