3dredstone commited on
Commit
6f2594f
·
verified ·
1 Parent(s): 39e856d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +111 -9
README.md CHANGED
@@ -1,12 +1,114 @@
1
  ---
2
- title: Bfd Rg
3
- emoji: 📉
4
- colorFrom: blue
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 5.33.2
8
- app_file: app.py
9
- pinned: false
 
 
 
 
 
 
 
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - Hemg/bone-fracture-detection
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-224
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - Bone
13
+ - Fracture
14
+ - Detection
15
+ - SigLIP2
16
+ - medical
17
+ - biology
18
  ---
19
 
20
+ ![Add a heading.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/AubiFwkdFgFgN6KfHIVhb.png)
21
+
22
+ # **Bone-Fracture-Detection**
23
+
24
+ > **Bone-Fracture-Detection** is a binary image classification model based on `google/siglip2-base-patch16-224`, trained to detect **fractures in bone X-ray images**. It is designed for use in **medical diagnostics**, **clinical triage**, and **radiology assistance systems**.
25
+
26
+
27
+ ```py
28
+ Classification Report:
29
+ precision recall f1-score support
30
+
31
+ Fractured 0.8633 0.7893 0.8246 4480
32
+ Not Fractured 0.8020 0.8722 0.8356 4383
33
+
34
+ accuracy 0.8303 8863
35
+ macro avg 0.8326 0.8308 0.8301 8863
36
+ weighted avg 0.8330 0.8303 0.8301 8863
37
+ ```
38
+
39
+ ![download.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/aoLW8h2vfmEPH60676rnb.png)
40
+
41
+
42
+ ---
43
+
44
+ ## **Label Classes**
45
+
46
+ The model distinguishes between the following bone conditions:
47
+
48
+ ```
49
+ 0: Fractured
50
+ 1: Not Fractured
51
+ ```
52
+
53
+ ---
54
+
55
+ ## **Installation**
56
+
57
+ ```bash
58
+ pip install transformers torch pillow gradio
59
+ ```
60
+
61
+ ---
62
+
63
+ ## **Example Inference Code**
64
+
65
+ ```python
66
+ import gradio as gr
67
+ from transformers import AutoImageProcessor, SiglipForImageClassification
68
+ from PIL import Image
69
+ import torch
70
+
71
+ # Load model and processor
72
+ model_name = "prithivMLmods/Bone-Fracture-Detection"
73
+ model = SiglipForImageClassification.from_pretrained(model_name)
74
+ processor = AutoImageProcessor.from_pretrained(model_name)
75
+
76
+ # ID to label mapping
77
+ id2label = {
78
+ "0": "Fractured",
79
+ "1": "Not Fractured"
80
+ }
81
+
82
+ def detect_fracture(image):
83
+ image = Image.fromarray(image).convert("RGB")
84
+ inputs = processor(images=image, return_tensors="pt")
85
+
86
+ with torch.no_grad():
87
+ outputs = model(**inputs)
88
+ logits = outputs.logits
89
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
90
+
91
+ prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))}
92
+ return prediction
93
+
94
+ # Gradio Interface
95
+ iface = gr.Interface(
96
+ fn=detect_fracture,
97
+ inputs=gr.Image(type="numpy"),
98
+ outputs=gr.Label(num_top_classes=2, label="Fracture Detection"),
99
+ title="Bone-Fracture-Detection",
100
+ description="Upload a bone X-ray image to detect if there is a fracture."
101
+ )
102
+
103
+ if __name__ == "__main__":
104
+ iface.launch()
105
+ ```
106
+
107
+ ---
108
+
109
+ ## **Applications**
110
+
111
+ * **Orthopedic Diagnostic Support**
112
+ * **Emergency Room Triage**
113
+ * **Automated Radiology Review**
114
+ * **Clinical Research in Bone Health**