Spaces:
Running
Running
fcernafukuzaki
commited on
Commit
路
d8cae64
1
Parent(s):
e986d84
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# -*- coding: utf-8 -*-
|
2 |
"""Deploy Barcelo demo.ipynb
|
3 |
-
|
4 |
Automatically generated by Colaboratory.
|
5 |
-
|
6 |
Original file is located at
|
7 |
https://colab.research.google.com/drive/1FxaL8DcYgvjPrWfWruSA5hvk3J81zLY9
|
8 |
-
|
9 |
![ ](https://www.vicentelopez.gov.ar/assets/images/logo-mvl.png)
|
10 |
-
|
11 |
# Modelo
|
12 |
-
|
13 |
YOLO es una familia de modelos de detecci贸n de objetos a escala compuesta entrenados en COCO dataset, e incluye una funcionalidad simple para Test Time Augmentation (TTA), model ensembling, hyperparameter evolution, and export to ONNX, CoreML and TFLite.
|
14 |
-
|
15 |
-
|
16 |
## Gradio Inferencia
|
17 |
-
|
18 |
![](https://i.ibb.co/982NS6m/header.png)
|
19 |
-
|
20 |
Este Notebook se acelera opcionalmente con un entorno de ejecuci贸n de GPU
|
21 |
-
|
22 |
-
|
23 |
----------------------------------------------------------------------
|
24 |
-
|
25 |
YOLOv5 Gradio demo
|
26 |
-
|
27 |
*Author: Ultralytics LLC and Gradio*
|
28 |
-
|
29 |
# C贸digo
|
30 |
"""
|
31 |
|
@@ -45,13 +69,13 @@ torch.hub.download_url_to_file('https://i.pinimg.com/originals/c2/ce/e0/c2cee056
|
|
45 |
|
46 |
# Model
|
47 |
#model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # force_reload=True to update
|
|
|
48 |
#model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt') # local model o google colab
|
49 |
-
|
50 |
#model = torch.hub.load('path/to/yolov5', 'custom', path='/content/yolov56.pt', source='local') # local repo
|
51 |
-
model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt', force_reload=True, autoshape=True, trust_repo=True)
|
52 |
|
53 |
HF_TOKEN = os.getenv("ZIKA_TOKEN_WRITE")
|
54 |
-
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "
|
55 |
|
56 |
def getQuantity(string):
|
57 |
contador_raw = ''.join(string.split(" ")[3:])
|
@@ -92,7 +116,8 @@ def arrayLista(resultado):
|
|
92 |
def yolo(size, iou, conf, im):
|
93 |
'''Wrapper fn for gradio'''
|
94 |
g = (int(size) / max(im.size)) # gain
|
95 |
-
im = im.resize((int(x * g) for x in im.size), Image.
|
|
|
96 |
|
97 |
model.iou = iou
|
98 |
|
@@ -118,14 +143,14 @@ in3 = gr.inputs.Slider(minimum=0, maximum=1, step=0.05, default=0.50, label='Umb
|
|
118 |
in4 = gr.inputs.Image(type='pil', label="Original Image")
|
119 |
|
120 |
out2 = gr.outputs.Image(type="pil", label="YOLOv5")
|
121 |
-
out3 = gr.outputs.Dataframe(label="
|
122 |
out4 = gr.outputs.JSON(label="JSON")
|
123 |
#-------------- Text-----
|
124 |
title = 'Trampas Barcel贸'
|
125 |
description = """
|
126 |
<p>
|
127 |
<center>
|
128 |
-
Sistemas de Desarrollado por Subsecretar铆a de
|
129 |
<img src="https://www.vicentelopez.gov.ar/assets/images/logo-mvl.png" alt="logo" width="250"/>
|
130 |
</center>
|
131 |
</p>
|
@@ -146,15 +171,10 @@ iface = gr.Interface(yolo,
|
|
146 |
flagging_options=["Correcto", "Incorrecto", "Casi correcto", "Error", "Otro"],
|
147 |
#flagging_callback=hf_writer
|
148 |
)
|
149 |
-
|
150 |
-
|
151 |
-
iface.launch(enable_queue=True)
|
152 |
-
#iface.launch(cache_examples=True, debug=True)
|
153 |
|
154 |
"""For YOLOv5 PyTorch Hub inference with **PIL**, **OpenCV**, **Numpy** or **PyTorch** inputs please see the full [YOLOv5 PyTorch Hub Tutorial](https://github.com/ultralytics/yolov5/issues/36).
|
155 |
-
|
156 |
-
|
157 |
## Citation
|
158 |
-
|
159 |
[![DOI](https://zenodo.org/badge/264818686.svg)](https://zenodo.org/badge/latestdoi/264818686)
|
160 |
-
"""
|
|
|
1 |
+
Hugging Face's logo
|
2 |
+
Hugging Face
|
3 |
+
Search models, datasets, users...
|
4 |
+
Models
|
5 |
+
Datasets
|
6 |
+
Spaces
|
7 |
+
Docs
|
8 |
+
Solutions
|
9 |
+
Pricing
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
Spaces:
|
14 |
+
|
15 |
+
Municipalidad-de-Vicente-Lopez
|
16 |
+
/
|
17 |
+
Trampas_Barcelo
|
18 |
+
|
19 |
+
|
20 |
+
like
|
21 |
+
0
|
22 |
+
App
|
23 |
+
Files
|
24 |
+
Community
|
25 |
+
Trampas_Barcelo
|
26 |
+
/
|
27 |
+
app.py
|
28 |
+
cesar's picture
|
29 |
+
cesar
|
30 |
+
Update app.py
|
31 |
+
e3b3548
|
32 |
+
34 minutes ago
|
33 |
+
raw
|
34 |
+
history
|
35 |
+
blame
|
36 |
+
contribute
|
37 |
+
delete
|
38 |
+
6.62 kB
|
39 |
# -*- coding: utf-8 -*-
|
40 |
"""Deploy Barcelo demo.ipynb
|
|
|
41 |
Automatically generated by Colaboratory.
|
|
|
42 |
Original file is located at
|
43 |
https://colab.research.google.com/drive/1FxaL8DcYgvjPrWfWruSA5hvk3J81zLY9
|
|
|
44 |
![ ](https://www.vicentelopez.gov.ar/assets/images/logo-mvl.png)
|
|
|
45 |
# Modelo
|
|
|
46 |
YOLO es una familia de modelos de detecci贸n de objetos a escala compuesta entrenados en COCO dataset, e incluye una funcionalidad simple para Test Time Augmentation (TTA), model ensembling, hyperparameter evolution, and export to ONNX, CoreML and TFLite.
|
|
|
|
|
47 |
## Gradio Inferencia
|
|
|
48 |
![](https://i.ibb.co/982NS6m/header.png)
|
|
|
49 |
Este Notebook se acelera opcionalmente con un entorno de ejecuci贸n de GPU
|
|
|
|
|
50 |
----------------------------------------------------------------------
|
|
|
51 |
YOLOv5 Gradio demo
|
|
|
52 |
*Author: Ultralytics LLC and Gradio*
|
|
|
53 |
# C贸digo
|
54 |
"""
|
55 |
|
|
|
69 |
|
70 |
# Model
|
71 |
#model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # force_reload=True to update
|
72 |
+
|
73 |
#model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt') # local model o google colab
|
74 |
+
model = torch.hub.load('ultralytics/yolov5', 'custom', path='best.pt', force_reload=True, autoshape=True) # local model o google colab
|
75 |
#model = torch.hub.load('path/to/yolov5', 'custom', path='/content/yolov56.pt', source='local') # local repo
|
|
|
76 |
|
77 |
HF_TOKEN = os.getenv("ZIKA_TOKEN_WRITE")
|
78 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "Municipalidad-de-Vicente-Lopez/Trampas_Barcelo_dataset")
|
79 |
|
80 |
def getQuantity(string):
|
81 |
contador_raw = ''.join(string.split(" ")[3:])
|
|
|
116 |
def yolo(size, iou, conf, im):
|
117 |
'''Wrapper fn for gradio'''
|
118 |
g = (int(size) / max(im.size)) # gain
|
119 |
+
im = im.resize((int(x * g) for x in im.size), Image.LANCZOS) # resize with antialiasing
|
120 |
+
|
121 |
|
122 |
model.iou = iou
|
123 |
|
|
|
143 |
in4 = gr.inputs.Image(type='pil', label="Original Image")
|
144 |
|
145 |
out2 = gr.outputs.Image(type="pil", label="YOLOv5")
|
146 |
+
out3 = gr.outputs.Dataframe(label="Cantidad_especie", headers=['Cantidad','Especie'])
|
147 |
out4 = gr.outputs.JSON(label="JSON")
|
148 |
#-------------- Text-----
|
149 |
title = 'Trampas Barcel贸'
|
150 |
description = """
|
151 |
<p>
|
152 |
<center>
|
153 |
+
Sistemas de Desarrollado por Subsecretar铆a de Modernizaci贸n del Municipio de Vicente L贸pez. Advertencia solo usar fotos provenientes de las trampas Barcel贸, no de celular o foto de internet.
|
154 |
<img src="https://www.vicentelopez.gov.ar/assets/images/logo-mvl.png" alt="logo" width="250"/>
|
155 |
</center>
|
156 |
</p>
|
|
|
171 |
flagging_options=["Correcto", "Incorrecto", "Casi correcto", "Error", "Otro"],
|
172 |
#flagging_callback=hf_writer
|
173 |
)
|
174 |
+
|
175 |
+
iface.launch(enable_queue=True, debug=True)
|
|
|
|
|
176 |
|
177 |
"""For YOLOv5 PyTorch Hub inference with **PIL**, **OpenCV**, **Numpy** or **PyTorch** inputs please see the full [YOLOv5 PyTorch Hub Tutorial](https://github.com/ultralytics/yolov5/issues/36).
|
|
|
|
|
178 |
## Citation
|
|
|
179 |
[![DOI](https://zenodo.org/badge/264818686.svg)](https://zenodo.org/badge/latestdoi/264818686)
|
180 |
+
"""
|