bodmedam commited on
Commit
733d6ff
·
verified ·
1 Parent(s): 448297f

Upload 10 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ example_images/image1.jpg filter=lfs diff=lfs merge=lfs -text
37
+ example_images/image2.jpg filter=lfs diff=lfs merge=lfs -text
38
+ example_images/image3.jpg filter=lfs diff=lfs merge=lfs -text
39
+ example_images/image6.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from PIL import Image
4
+ import cv2
5
+ from ultralytics import YOLO
6
+ from transformers import pipeline
7
+ import os
8
+
9
+ # Modelle laden
10
+ yolo_model = YOLO("./best.pt")
11
+ dino_model = pipeline("zero-shot-object-detection", model="IDEA-Research/grounding-dino-tiny")
12
+
13
+ # YOLOv8-Erkennung
14
+ def detect_with_yolo(image: Image.Image):
15
+ results = yolo_model(np.array(image))[0]
16
+ return Image.fromarray(results.plot())
17
+
18
+ # Grounding DINO-Erkennung
19
+ def detect_with_grounding_dino(image: Image.Image, prompt="license plate"):
20
+ results = dino_model(image, candidate_labels=[prompt])
21
+ image_np = np.array(image).copy()
22
+
23
+ if not results:
24
+ return Image.fromarray(image_np)
25
+
26
+ results = [result for result in results if result["score"] > 0.4]
27
+
28
+ for result in results:
29
+ box = result["box"]
30
+ score = result["score"]
31
+ label = "license plate"
32
+
33
+ x1, y1, x2, y2 = int(box["xmin"]), int(box["ymin"]), int(box["xmax"]), int(box["ymax"])
34
+ image_np = cv2.rectangle(image_np, (x1, y1), (x2, y2), (0, 255, 0), 2)
35
+ image_np = cv2.putText(image_np, f"{label} ({score:.2f})", (x1, y1 - 10),
36
+ cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 1)
37
+
38
+ return Image.fromarray(image_np)
39
+
40
+ # Verarbeitung der Bilder
41
+ def process_image(image):
42
+ yolo_out = detect_with_yolo(image)
43
+ dino_out = detect_with_grounding_dino(image)
44
+ return yolo_out, dino_out
45
+
46
+ # Beispielbilder definieren
47
+ example_images = [
48
+ ["example_images/image1.jpg"],
49
+ ["example_images/image2.jpg"],
50
+ ["example_images/image3.jpg"],
51
+ ["example_images/image4.jpg"],
52
+ ["example_images/image5.jpg"],
53
+ ["example_images/image6.jpg"],
54
+ ["example_images/image7.jpg"]
55
+ ]
56
+
57
+ # Gradio-Interface
58
+ app = gr.Interface(
59
+ fn=process_image,
60
+ inputs=gr.Image(type="pil"),
61
+ outputs=[
62
+ gr.Image(label="YOLOv8 Detection"),
63
+ gr.Image(label="Grounding DINO (Zero-Shot) Detection")
64
+ ],
65
+ examples=example_images,
66
+ title="Kennzeichenerkennung",
67
+ description="Lade ein Bild hoch oder wähle ein Beispielbild und vergleiche die Ergebnisse."
68
+ )
69
+
70
+ if __name__ == "__main__":
71
+ app.launch()
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bafcfd85756a4f6b6c026a515ba2b92b03cab09784ddbd3bbd1523adb5d9705
3
+ size 6217379
example_images/image1.jpg ADDED

Git LFS Details

  • SHA256: 432d6d01863d8611a89b280a6eb56aa71545788c088f98dd91a0bcc886cd272a
  • Pointer size: 131 Bytes
  • Size of remote file: 123 kB
example_images/image2.jpg ADDED

Git LFS Details

  • SHA256: 0cf9cbd615ef919cba2e4f3512e77c6cef7fb22d0395ccd5441038f7f741284d
  • Pointer size: 131 Bytes
  • Size of remote file: 108 kB
example_images/image3.jpg ADDED

Git LFS Details

  • SHA256: 951279ea7846ead910ad9c30489825b51fa0e216d10ce836ec3cea0598a7844a
  • Pointer size: 131 Bytes
  • Size of remote file: 160 kB
example_images/image4.jpg ADDED
example_images/image5.jpg ADDED
example_images/image6.jpg ADDED

Git LFS Details

  • SHA256: 854b736258bac1923b5a8d6b1167d388945341b4e9dc953a85bc27f05ac9c85f
  • Pointer size: 131 Bytes
  • Size of remote file: 164 kB
example_images/image7.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ ultralytics
2
+ gradio
3
+ transformers
4
+ torch
5
+ opencv-python-headless