Spaces:
Runtime error
Runtime error
Geraldine J
commited on
Commit
路
fc237d8
1
Parent(s):
8c9db40
Update dataframe
Browse files
app.py
CHANGED
@@ -41,6 +41,7 @@ from botocore.exceptions import NoCredentialsError
|
|
41 |
import tempfile
|
42 |
import io
|
43 |
from PIL import Image
|
|
|
44 |
# Images
|
45 |
torch.hub.download_url_to_file('https://i.pinimg.com/564x/18/0b/00/180b00e454362ff5caabe87d9a763a6f.jpg', 'ejemplo1.jpg')
|
46 |
torch.hub.download_url_to_file('https://i.pinimg.com/564x/3b/2f/d4/3b2fd4b6881b64429f208c5f32e5e4be.jpg', 'ejemplo2.jpg')
|
@@ -53,27 +54,11 @@ region = os.environ['region']
|
|
53 |
def removeStr(string):
|
54 |
return string.replace(" ", "")
|
55 |
|
56 |
-
def
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
b = 'Lobo marino'
|
62 |
-
if y:
|
63 |
-
b = 'Pelicano'
|
64 |
-
if z:
|
65 |
-
d = 'Pelicano'
|
66 |
-
if(b=='Lobo marino' or b=='Pelicano'):
|
67 |
-
strlist =[]
|
68 |
-
strlist2 =[]
|
69 |
-
strlist.append(removeStr(a))
|
70 |
-
strlist.append(b)
|
71 |
-
if d=='Pelicano':
|
72 |
-
strlist2.append(removeStr(c))
|
73 |
-
strlist2.append(d)
|
74 |
-
strlista = [strlist,strlist2]
|
75 |
-
df = pd.DataFrame(strlista,columns=['Cantidad','Especie'])
|
76 |
-
return df
|
77 |
|
78 |
#Imagen temporal guardada en upload_file
|
79 |
def tempFileJSON(img_file):
|
@@ -158,7 +143,7 @@ def yolo(size, iou, conf, im):
|
|
158 |
fileImg = tempFileJSON(im_bytes)
|
159 |
#Enviando la informacion al contador de especies
|
160 |
results6 = qtyEspecies(results5,results3,fileImg)
|
161 |
-
lista2 =
|
162 |
return Image.fromarray(results2.ims[0]), lista2, results6
|
163 |
except Exception as e:
|
164 |
logging.error(e, exc_info=True)
|
@@ -171,7 +156,7 @@ in3 = gr.inputs.Slider(minimum=0, maximum=1, step=0.05, default=0.50, label='Umb
|
|
171 |
in4 = gr.inputs.Image(type='pil', label="Original Image")
|
172 |
|
173 |
out2 = gr.outputs.Image(type="pil", label="Identificaci贸n con Yolov5")
|
174 |
-
out3 = gr.outputs.Dataframe(label="Descripci贸n", headers=['Cantidad','Especie'])
|
175 |
out4 = gr.outputs.JSON(label="JSON")
|
176 |
#-------------- Text-----
|
177 |
title = 'OceanApp'
|
|
|
41 |
import tempfile
|
42 |
import io
|
43 |
from PIL import Image
|
44 |
+
from pandas import json_normalize
|
45 |
# Images
|
46 |
torch.hub.download_url_to_file('https://i.pinimg.com/564x/18/0b/00/180b00e454362ff5caabe87d9a763a6f.jpg', 'ejemplo1.jpg')
|
47 |
torch.hub.download_url_to_file('https://i.pinimg.com/564x/3b/2f/d4/3b2fd4b6881b64429f208c5f32e5e4be.jpg', 'ejemplo2.jpg')
|
|
|
54 |
def removeStr(string):
|
55 |
return string.replace(" ", "")
|
56 |
|
57 |
+
def arrayListax(json_data):
|
58 |
+
dict = json_data
|
59 |
+
df2 = json_normalize(dict['detail'])
|
60 |
+
#df = pd.DataFrame(df2,columns=['Cantidad','Especie'])
|
61 |
+
return df2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
#Imagen temporal guardada en upload_file
|
64 |
def tempFileJSON(img_file):
|
|
|
143 |
fileImg = tempFileJSON(im_bytes)
|
144 |
#Enviando la informacion al contador de especies
|
145 |
results6 = qtyEspecies(results5,results3,fileImg)
|
146 |
+
lista2 = arrayListax(results6)
|
147 |
return Image.fromarray(results2.ims[0]), lista2, results6
|
148 |
except Exception as e:
|
149 |
logging.error(e, exc_info=True)
|
|
|
156 |
in4 = gr.inputs.Image(type='pil', label="Original Image")
|
157 |
|
158 |
out2 = gr.outputs.Image(type="pil", label="Identificaci贸n con Yolov5")
|
159 |
+
out3 = gr.outputs.Dataframe(type="pandas", label="Descripci贸n", headers=['Cantidad','Especie'])
|
160 |
out4 = gr.outputs.JSON(label="JSON")
|
161 |
#-------------- Text-----
|
162 |
title = 'OceanApp'
|