Spaces:
Runtime error
Runtime error
lakshmi324
commited on
Commit
•
1783472
1
Parent(s):
cf081fd
Initial Commit
Browse files- Trained_Model.pth +3 -0
- app.py +30 -0
- requirements.txt +3 -0
Trained_Model.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ca82f6a925c4ce9534bfb7e07dfb978c07a87eb0074eb00bee635345688d6cbc
|
3 |
+
size 165746739
|
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
|
3 |
+
from torchvision import transforms
|
4 |
+
from detecto import core
|
5 |
+
from detecto import utils
|
6 |
+
from detecto.visualize import show_labeled_image
|
7 |
+
from detecto.core import Model
|
8 |
+
import matplotlib.pyplot as plt
|
9 |
+
import matplotlib.image as img
|
10 |
+
|
11 |
+
|
12 |
+
transform_img = transforms.Compose([transforms.ToPILImage(),
|
13 |
+
transforms.Resize(400),
|
14 |
+
transforms.RandomHorizontalFlip(0.5),
|
15 |
+
transforms.ToTensor(),
|
16 |
+
utils.normalize_transform(),])
|
17 |
+
|
18 |
+
|
19 |
+
labels = ['damage','BG']
|
20 |
+
model = Model.load('/content/drive/MyDrive/Trained_Model.pth', labels)
|
21 |
+
|
22 |
+
def prediction_defect(new_image,model = model):
|
23 |
+
'''Function takes input of the damaged vehicle
|
24 |
+
and provides the damaged area of the vehicle
|
25 |
+
'''
|
26 |
+
image = utils.read_image(new_image)
|
27 |
+
new_image = transform_img(image)
|
28 |
+
labels, boxes, scores = model.predict(image)
|
29 |
+
top = len(scores[scores > .5])
|
30 |
+
show_labeled_image(image, boxes[:top], labels[:top])
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
pandas
|
2 |
+
detecto
|
3 |
+
torchvision
|