beingamit99
commited on
Commit
·
c3a9d45
1
Parent(s):
03f6a59
Update README.md
Browse files
README.md
CHANGED
@@ -40,20 +40,20 @@ Feel free to explore and integrate this model into your applications for accurat
|
|
40 |
### Approach
|
41 |
|
42 |
### First Approach
|
43 |
-
|
44 |
import numpy as np
|
45 |
from PIL import Image
|
46 |
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
47 |
|
48 |
-
#Load the model and image processor
|
49 |
processor = AutoImageProcessor.from_pretrained("beingamit99/car_damage_detection")
|
50 |
model = AutoModelForImageClassification.from_pretrained("beingamit99/car_damage_detection")
|
51 |
|
52 |
-
#Load and process the image
|
53 |
image = Image.open(IMAGE)
|
54 |
inputs = processor(images=image, return_tensors="pt")
|
55 |
|
56 |
-
#Make predictions
|
57 |
outputs = model(**inputs)
|
58 |
logits = outputs.logits.detach().cpu().numpy()
|
59 |
predicted_class_id = np.argmax(logits)
|
@@ -61,15 +61,12 @@ predicted_proba = np.max(logits)
|
|
61 |
label_map = model.config.id2label
|
62 |
predicted_class_name = label_map[predicted_class_id]
|
63 |
|
64 |
-
#Print the results
|
65 |
-
print(f"Predicted class: {predicted_class_name} (probability: {predicted_proba:.4f}
|
66 |
-
</code>
|
67 |
|
68 |
### Second Approach
|
69 |
-
|
70 |
from transformers import pipeline
|
71 |
-
|
72 |
#Create a classification pipeline
|
73 |
pipe = pipeline("image-classification", model="beingamit99/car_damage_detection")
|
74 |
pipe(IMAGE)
|
75 |
-
</code>
|
|
|
40 |
### Approach
|
41 |
|
42 |
### First Approach
|
43 |
+
```python
|
44 |
import numpy as np
|
45 |
from PIL import Image
|
46 |
from transformers import AutoImageProcessor, AutoModelForImageClassification
|
47 |
|
48 |
+
# Load the model and image processor
|
49 |
processor = AutoImageProcessor.from_pretrained("beingamit99/car_damage_detection")
|
50 |
model = AutoModelForImageClassification.from_pretrained("beingamit99/car_damage_detection")
|
51 |
|
52 |
+
# Load and process the image
|
53 |
image = Image.open(IMAGE)
|
54 |
inputs = processor(images=image, return_tensors="pt")
|
55 |
|
56 |
+
# Make predictions
|
57 |
outputs = model(**inputs)
|
58 |
logits = outputs.logits.detach().cpu().numpy()
|
59 |
predicted_class_id = np.argmax(logits)
|
|
|
61 |
label_map = model.config.id2label
|
62 |
predicted_class_name = label_map[predicted_class_id]
|
63 |
|
64 |
+
# Print the results
|
65 |
+
print(f"Predicted class: {predicted_class_name} (probability: {predicted_proba:.4f}")
|
|
|
66 |
|
67 |
### Second Approach
|
68 |
+
```python
|
69 |
from transformers import pipeline
|
|
|
70 |
#Create a classification pipeline
|
71 |
pipe = pipeline("image-classification", model="beingamit99/car_damage_detection")
|
72 |
pipe(IMAGE)
|
|