npc0 commited on
Commit
7a25912
1 Parent(s): af06ad9

Testing ViT

Browse files
Files changed (1) hide show
  1. app.py +14 -9
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
- # 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)
@@ -36,10 +36,13 @@ def read_license_number(img):
36
 
37
 
38
  def zero_shot_classification(image, labels):
 
39
  inputs = processor(text=labels,
40
  images=image,
41
  return_tensors="pt",
42
  padding=True)
 
 
43
  outputs = model(**inputs)
44
  logits_per_image = outputs.logits_per_image # this is the image-text similarity score
45
  return logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
@@ -68,7 +71,9 @@ def check_solarplant_broken(image):
68
 
69
 
70
  def greet(img):
71
- lns = read_license_number(img)
 
 
72
  if len(lns):
73
  # return (seg,
74
  return ("車牌: " + '; '.join(lns) + "\n\n" \
 
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)
 
36
 
37
 
38
  def zero_shot_classification(image, labels):
39
+ print(type(image))
40
  inputs = processor(text=labels,
41
  images=image,
42
  return_tensors="pt",
43
  padding=True)
44
+ print(type(inputs))
45
+ print(inputs)
46
  outputs = model(**inputs)
47
  logits_per_image = outputs.logits_per_image # this is the image-text similarity score
48
  return logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
 
71
 
72
 
73
  def greet(img):
74
+ print(type(img))
75
+ # lns = read_license_number(img)
76
+ lns = [1,2,3]
77
  if len(lns):
78
  # return (seg,
79
  return ("車牌: " + '; '.join(lns) + "\n\n" \