Atualli commited on
Commit
dccc4d6
0 Parent(s):

Duplicate from Atualli/yolox15g

Browse files
Files changed (7) hide show
  1. .gitattributes +35 -0
  2. README.md +14 -0
  3. app.py +79 -0
  4. app1.py +81 -0
  5. checkYolov5g.sh +16 -0
  6. requirements.txt +2 -0
  7. telegramCrise.sh +1 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Yolov5g
3
+ emoji: 🏆
4
+ colorFrom: yellow
5
+ colorTo: blue
6
+ sdk: gradio
7
+ sdk_version: 3.36.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ duplicated_from: Atualli/yolox15g
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ import json
4
+ import yolov5
5
+
6
+ # Images
7
+ torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg', 'zidane.jpg')
8
+ torch.hub.download_url_to_file('https://raw.githubusercontent.com/WongKinYiu/yolov7/main/inference/images/image3.jpg', 'image3.jpg')
9
+ torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt','yolov5s.pt')
10
+
11
+ model_path = "yolov5x.pt" #"yolov5s.pt" #"yolov5m.pt", "yolov5l.pt", "yolov5x.pt",
12
+ image_size = 640,
13
+ conf_threshold = 0.25,
14
+ iou_threshold = 0.45,
15
+ model = yolov5.load(model_path, device="cpu")
16
+
17
+ def yolov5_inference(
18
+ image: gr.inputs.Image = None,
19
+
20
+ ):
21
+ """
22
+ YOLOv5 inference function
23
+ Args:
24
+ image: Input image
25
+ model_path: Path to the model
26
+ image_size: Image size
27
+ conf_threshold: Confidence threshold
28
+ iou_threshold: IOU threshold
29
+ Returns:
30
+ Rendered image
31
+ """
32
+
33
+ results = model([image], size=image_size)
34
+ tensor = {
35
+ "tensorflow": [
36
+ ]
37
+ }
38
+
39
+ if results.pred is not None:
40
+ for i, element in enumerate(results.pred[0]):
41
+ object = {}
42
+ #print (element[0])
43
+ itemclass = round(element[5].item())
44
+ object["classe"] = itemclass
45
+ object["nome"] = results.names[itemclass]
46
+ object["score"] = element[4].item()
47
+ object["x"] = element[0].item()
48
+ object["y"] = element[1].item()
49
+ object["w"] = element[2].item()
50
+ object["h"] = element[3].item()
51
+ tensor["tensorflow"].append(object)
52
+
53
+
54
+
55
+ text = json.dumps(tensor)
56
+ #print (text)
57
+ return text #results.render()[0]
58
+
59
+
60
+ inputs = [
61
+ gr.inputs.Image(type="pil", label="Input Image"),
62
+ ]
63
+
64
+ outputs = gr.outputs.Image(type="filepath", label="Output Image")
65
+ title = "YOLOv5"
66
+ description = "YOLOv5 is a family of object detection models pretrained on COCO dataset. This model is a pip implementation of the original YOLOv5 model."
67
+
68
+ examples = [['zidane.jpg'], ['image3.jpg']]
69
+ demo_app = gr.Interface(
70
+ fn=yolov5_inference,
71
+ inputs=inputs,
72
+ outputs=["text"],
73
+ title=title,
74
+ examples=examples,
75
+ #cache_examples=True,
76
+ #live=True,
77
+ #theme='huggingface',
78
+ )
79
+ demo_app.launch(debug=True, enable_queue=True)
app1.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ import json
4
+ import yolov5
5
+
6
+ # Images
7
+ torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/raw/master/data/images/zidane.jpg', 'zidane.jpg')
8
+ torch.hub.download_url_to_file('https://raw.githubusercontent.com/WongKinYiu/yolov7/main/inference/images/image3.jpg', 'image3.jpg')
9
+ torch.hub.download_url_to_file('https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt','yolov5s.pt')
10
+
11
+ model_path = "yolov5x.pt" #"yolov5s.pt" #"yolov5m.pt", "yolov5l.pt", "yolov5x.pt",
12
+ image_size = 640,
13
+ conf_threshold = 0.25,
14
+ iou_threshold = 0.45,
15
+ model = yolov5.load(model_path, device="cpu")
16
+
17
+ def yolov5_inference(
18
+ image: gr.inputs.Image = None,
19
+
20
+ ):
21
+ """
22
+ YOLOv5 inference function
23
+ Args:
24
+ image: Input image
25
+ model_path: Path to the model
26
+ image_size: Image size
27
+ conf_threshold: Confidence threshold
28
+ iou_threshold: IOU threshold
29
+ Returns:
30
+ Rendered image
31
+ """
32
+
33
+ results = model([image], size=image_size)
34
+ tensor = {
35
+ "tensorflow": [
36
+ ]
37
+ }
38
+
39
+ if results.pred is not None:
40
+ for i, element in enumerate(results.pred[0]):
41
+ object = {}
42
+ #print (element[0])
43
+ itemclass = round(element[5].item())
44
+ object["classe"] = itemclass
45
+ object["nome"] = results.names[itemclass]
46
+ object["score"] = element[4].item()
47
+ object["x"] = element[0].item()
48
+ object["y"] = element[1].item()
49
+ object["w"] = element[2].item()
50
+ object["h"] = element[3].item()
51
+ tensor["tensorflow"].append(object)
52
+
53
+
54
+
55
+ text = json.dumps(tensor)
56
+ #print (text)
57
+ return text #results.render()[0]
58
+
59
+
60
+ inputs = [
61
+ gr.inputs.Image(type="pil", label="Input Image"),
62
+ ]
63
+
64
+ outputs = gr.outputs.Image(type="filepath", label="Output Image")
65
+ title = "YOLOv5"
66
+ description = "YOLOv5 is a family of object detection models pretrained on COCO dataset. This model is a pip implementation of the original YOLOv5 model."
67
+
68
+ examples = [['zidane.jpg'], ['image3.jpg']]
69
+ demo_app = gr.Interface(
70
+ fn=yolov5_inference,
71
+ inputs=inputs,
72
+ outputs=["text"],
73
+ title=title,
74
+ examples=examples,
75
+ #cache_examples=True,
76
+ #live=True,
77
+ #theme='huggingface',
78
+ )
79
+ demo_app.launch(debug=True, server_name="192.168.0.153", server_port=8080, enable_queue=True)
80
+ demo_app.launch(debug=True, enable_queue=True)
81
+ #demo_app.launch(debug=True, server_port=8083, enable_queue=True)
checkYolov5g.sh ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/sh
2
+ export path=/home/atualli/.local/lib/python3.8/site-packages:$PATH
3
+ cd ~/Projetos/huggingface/yolov7
4
+ SERVER=192.168.0.153
5
+ PORT=8080
6
+
7
+ if lsof -Pi :$PORT -sTCP:LISTEN -t >/dev/null ; then
8
+ echo "running"
9
+ else
10
+ ./telegramCrise.sh "reiniciando_yolox_V5G_linux_192.168.0.153:8080"
11
+ pkill -f app1.py
12
+ python app1.py &
13
+ echo "not running"
14
+ fi
15
+
16
+
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch
2
+ yolov5
telegramCrise.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ curl -X POST "https://api.telegram.org/bot766543741:AAE0oO_ni_QYkfS8tZxC-VZt0RJztFiZNHc/sendMessage?chat_id=-927074982&text=$1"