sofiiafolv commited on
Commit
cf76678
·
1 Parent(s): 74b2a48

added all necessary files for application

Browse files
Files changed (8) hide show
  1. .gitattributes +3 -0
  2. app.py +56 -0
  3. example1.jpg +3 -0
  4. example2.jpg +3 -0
  5. example3.jpg +3 -0
  6. gc10-det.pth +3 -0
  7. neu-det.pth +3 -0
  8. requirements.txt +2 -0
.gitattributes CHANGED
@@ -33,3 +33,6 @@ 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
+ .pth filter=lfs diff=lfs merge=lfs -text
37
+ .jpg filter=lfs diff=lfs merge=lfs -text
38
+ *.jpg filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import supervision as sv
3
+ from rfdetr import RFDETRBase
4
+
5
+ models = {
6
+ "GC10-DET": "src/models/gc10-det.pth",
7
+ "NEU-DET": "src/models/neu-det.pth"
8
+ }
9
+
10
+ def predict(model_name, img, conf, iou):
11
+ model_path = models[model_name]
12
+ model = RFDETRBase(pretrain_weights=model_path)
13
+ model.optimize_for_inference()
14
+
15
+ results = model.predict(img, threshold=conf)
16
+ results = results.with_nmm(threshold=iou)
17
+
18
+ labels = [f"defect {confidence:.2f}" for confidence in results.confidence]
19
+
20
+ annotated_image = img.copy()
21
+ annotated_image = sv.BoxAnnotator().annotate(annotated_image, results)
22
+ annotated_image = sv.LabelAnnotator().annotate(annotated_image, results, labels)
23
+
24
+ return annotated_image
25
+
26
+ base_conf, base_iou = 0.25, 0.5
27
+ title = "Detection with RF-DETR trained on NEU-DET and GC10-DET"
28
+ des = """
29
+ **Instructions:**
30
+ 1. Choose a model:
31
+ \- **GC10-DET** - for images from the GC10 dataset (10 defect types, steel surface images)
32
+ \- **NEU-DET** - for images from the NEU dataset (6 defect types, steel strip images)
33
+ 2. Upload Image.
34
+ 3. Adjust thresholds
35
+ 4. Click the **Submit** button. Wait while predictions are generated.
36
+ """
37
+ interface = gr.Interface(
38
+ fn=predict,
39
+ inputs=[
40
+ gr.Dropdown(list(models.keys()), label="Select Model"),
41
+ 'image',
42
+ gr.Slider(maximum=1, minimum=0, value=base_conf, label="Confidence Threshold"),
43
+ gr.Slider(maximum=1, minimum=0, value=base_iou, label="NMM IoU Threshold")
44
+ ],
45
+ outputs=["image"],
46
+ title=title,
47
+ description=des,
48
+ examples=[
49
+ ["GC10-DET", "example1.jpg", base_conf, base_iou],
50
+ ["GC10-DET", "example2.jpg", base_conf, base_iou],
51
+ ["NEU-DET", "example3.jpg", base_conf, base_iou]
52
+ ]
53
+ )
54
+
55
+ interface.launch()
56
+
example1.jpg ADDED

Git LFS Details

  • SHA256: d1810d01c681efcdb073e61c66a525d200433e4509cac5227b3fbc2401918eeb
  • Pointer size: 131 Bytes
  • Size of remote file: 458 kB
example2.jpg ADDED

Git LFS Details

  • SHA256: 44b52d7c872725cd04d84c77bad0fa2e44679a00658611afe393558641538140
  • Pointer size: 131 Bytes
  • Size of remote file: 355 kB
example3.jpg ADDED

Git LFS Details

  • SHA256: 7d92c3048cb2e54beff63e3a11a6d124578a6f27dbadb697e3d7c871c824eb69
  • Pointer size: 129 Bytes
  • Size of remote file: 7.94 kB
gc10-det.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a234a044908796b7d6f065d845c7368461c08ec3b4b86ee9c175ad911df7bb26
3
+ size 127619710
neu-det.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f78db58695d4d66bfb2437c17710cc21e8f616b8136de6de158e616b1155805
3
+ size 127619710
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ git+https://github.com/roboflow/rf-detr.git