PranomVignesh commited on
Commit
40dcf79
·
0 Parent(s):

Duplicate from PranomVignesh/yolov5

Browse files
Files changed (5) hide show
  1. .gitattributes +31 -0
  2. README.md +14 -0
  3. app.py +67 -0
  4. best.pt +3 -0
  5. requirements.txt +6 -0
.gitattributes ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.npy filter=lfs diff=lfs merge=lfs -text
13
+ *.npz filter=lfs diff=lfs merge=lfs -text
14
+ *.onnx filter=lfs diff=lfs merge=lfs -text
15
+ *.ot filter=lfs diff=lfs merge=lfs -text
16
+ *.parquet filter=lfs diff=lfs merge=lfs -text
17
+ *.pickle filter=lfs diff=lfs merge=lfs -text
18
+ *.pkl filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pt filter=lfs diff=lfs merge=lfs -text
21
+ *.pth filter=lfs diff=lfs merge=lfs -text
22
+ *.rar filter=lfs diff=lfs merge=lfs -text
23
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
24
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
25
+ *.tflite filter=lfs diff=lfs merge=lfs -text
26
+ *.tgz filter=lfs diff=lfs merge=lfs -text
27
+ *.wasm filter=lfs diff=lfs merge=lfs -text
28
+ *.xz filter=lfs diff=lfs merge=lfs -text
29
+ *.zip filter=lfs diff=lfs merge=lfs -text
30
+ *.zst filter=lfs diff=lfs merge=lfs -text
31
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Yolov5
3
+ emoji: 🏃
4
+ colorFrom: gray
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 3.3
8
+ app_file: app.py
9
+ pinned: false
10
+ license: gpl-3.0
11
+ duplicated_from: PranomVignesh/yolov5
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ import yolov5
4
+ from transformers import pipeline
5
+
6
+ pipeline = pipeline(task="image-classification", model="PranomVignesh/Police-vs-Public")
7
+
8
+ # from transformers import AutoFeatureExtractor, AutoModelForImageClassification
9
+
10
+ # extractor = AutoFeatureExtractor.from_pretrained("PranomVignesh/Police-vs-Public")
11
+ # model = AutoModelForImageClassification.from_pretrained("PranomVignesh/Police-vs-Public")
12
+
13
+ # Images
14
+ # torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg', 'zidane.jpg')
15
+ # torch.hub.download_url_to_file('https://raw.githubusercontent.com/WongKinYiu/yolov7/main/inference/images/image3.jpg', 'image3.jpg')
16
+
17
+ def yolov5_inference(
18
+ image
19
+ ):
20
+ """
21
+ YOLOv5 inference function
22
+ Args:
23
+ image: Input image
24
+ model_path: Path to the model
25
+ image_size: Image size
26
+ conf_threshold: Confidence threshold
27
+ iou_threshold: IOU threshold
28
+ Returns:
29
+ Rendered image
30
+ """
31
+ model = yolov5.load('./best.pt', device="cpu")
32
+ results = model([image], size=224)
33
+
34
+ # outputs = model(**inputs)
35
+ # logits = outputs.logits
36
+ # probabilities = torch.softmax(logits, dim=1).tolist()[0]
37
+
38
+ # classes = ['Police/Authorized Personnel', 'Public/Unauthorized Person']
39
+
40
+ # output = {name: float(prob) for name, prob in zip(classes, probabilities)}
41
+
42
+ probabilities = pipeline(image)
43
+ output = {p["label"]: p["score"] for p in probabilities}
44
+
45
+ return results.render()[0],output
46
+
47
+
48
+ inputs = gr.Image(type="pil")
49
+ outputs = [
50
+ gr.Image(type="pil"),
51
+ gr.Label()
52
+ ]
53
+ title = "Detection"
54
+ description = "YOLOv5 is a family of object detection models pretrained on COCO dataset. This model is a pip implementation of the original YOLOv5 model."
55
+
56
+ # examples = [['zidane.jpg', 'yolov5s.pt', 640, 0.25, 0.45], ['image3.jpg', 'yolov5s.pt', 640, 0.25, 0.45]]
57
+ demo_app = gr.Interface(
58
+ fn=yolov5_inference,
59
+ inputs=inputs,
60
+ outputs=outputs,
61
+ title=title,
62
+ # examples=examples,
63
+ # cache_examples=True,
64
+ # live=True,
65
+ # theme='huggingface',
66
+ )
67
+ demo_app.launch(debug=True, enable_queue=True)
best.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:221d921ee575adba1f5a069f513c0c06d19815cb9a470b0bcbefaa2262d7b88a
3
+ size 92659861
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ torch
2
+ yolov5
3
+ transformers
4
+ opencv-python
5
+ gradio
6
+