Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,15 +7,15 @@ from transformers import CLIPProcessor, CLIPModel
|
|
7 |
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
8 |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
9 |
|
10 |
-
#
|
11 |
-
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
def license_plate_detect(img):
|
21 |
results = model(img, size=640)
|
@@ -62,23 +62,26 @@ def check_solarplant_installed_by_image(image, output_label=False):
|
|
62 |
return zero_shot_class_labels[probs.argmax().item()]
|
63 |
return probs.argmax().item() == 0
|
64 |
|
65 |
-
def check_solarplant_broken(image):
|
66 |
zero_shot_class_labels = ["white broken solar panel",
|
67 |
"normal black solar panel grids"]
|
68 |
probs = zero_shot_classification(image, zero_shot_class_labels)
|
69 |
idx = probs.argmax().item()
|
70 |
-
|
|
|
|
|
71 |
|
72 |
|
73 |
def greet(img):
|
74 |
print(type(img))
|
75 |
-
|
76 |
-
lns = ['1','2','3']
|
77 |
if len(lns):
|
|
|
78 |
# return (seg,
|
79 |
return ("่ป็๏ผ " + '; '.join(lns) + "\n\n" \
|
80 |
-
+ "้กๅ๏ผ "+
|
81 |
-
+ "็ๆ
๏ผ" + check_solarplant_broken(img)
|
|
|
82 |
return (img, "็ฉบๅฐใใใ")
|
83 |
|
84 |
|
|
|
7 |
model = CLIPModel.from_pretrained("openai/clip-vit-base-patch32")
|
8 |
processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")
|
9 |
|
10 |
+
# load model
|
11 |
+
model = yolov5.load('keremberke/yolov5m-license-plate')
|
12 |
|
13 |
+
# set model parameters
|
14 |
+
model.conf = 0.5 # NMS confidence threshold
|
15 |
+
model.iou = 0.25 # NMS IoU threshold
|
16 |
+
model.agnostic = False # NMS class-agnostic
|
17 |
+
model.multi_label = False # NMS multiple labels per box
|
18 |
+
model.max_det = 1000 # maximum number of detections per image
|
19 |
|
20 |
def license_plate_detect(img):
|
21 |
results = model(img, size=640)
|
|
|
62 |
return zero_shot_class_labels[probs.argmax().item()]
|
63 |
return probs.argmax().item() == 0
|
64 |
|
65 |
+
def check_solarplant_broken(image, output_label=False):
|
66 |
zero_shot_class_labels = ["white broken solar panel",
|
67 |
"normal black solar panel grids"]
|
68 |
probs = zero_shot_classification(image, zero_shot_class_labels)
|
69 |
idx = probs.argmax().item()
|
70 |
+
if output_label:
|
71 |
+
return zero_shot_class_labels[idx].split(" ")[1-idx]
|
72 |
+
return idx == 0
|
73 |
|
74 |
|
75 |
def greet(img):
|
76 |
print(type(img))
|
77 |
+
lns = read_license_number(img)
|
|
|
78 |
if len(lns):
|
79 |
+
planttype = check_solarplant_installed_by_image(img, True)
|
80 |
# return (seg,
|
81 |
return ("่ป็๏ผ " + '; '.join(lns) + "\n\n" \
|
82 |
+
+ "้กๅ๏ผ "+ planttype + "\n\n" \
|
83 |
+
+ "็ๆ
๏ผ" + (check_solarplant_broken(img, True)
|
84 |
+
if 'with' in planttype else 'normal'))
|
85 |
return (img, "็ฉบๅฐใใใ")
|
86 |
|
87 |
|