Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -299,42 +299,42 @@ class DetectionPredictor(BasePredictor):
|
|
299 |
|
300 |
outputs = deepsort.update(xywhs, confss, oids, im0)
|
301 |
|
302 |
-
with open('/pulse.csv', 'a') as f:
|
303 |
# create the csv writer
|
304 |
-
writer = csv.writer(f)
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
|
310 |
-
f2 = open('/vehicles_data.csv', "w+")
|
311 |
-
f2.close()
|
312 |
-
with open('/vehicles_data.csv', 'a') as f:
|
313 |
-
writer2 = csv.writer(f)
|
314 |
-
header = ['id', 'class', 'speed', 'weight']
|
315 |
-
writer2.writerow(header)
|
316 |
-
|
317 |
-
df = pd.read_csv("/pulse.csv")
|
318 |
-
df['time'] = pd.to_datetime(df['time'], format = '%H:%M:%S %d.%m.%Y')
|
319 |
|
320 |
|
321 |
-
df.index = df['time']
|
322 |
-
del df['time']
|
323 |
|
324 |
-
try:
|
325 |
-
fig, ax = plt.subplots()
|
326 |
#plt.clf()
|
327 |
-
sns.lineplot(df)
|
328 |
#ax.set_xticklabels([t.get_text().split(".")[0] for t in ax.get_xticklabels()])
|
329 |
-
ax.set_xticklabels([pd.to_datetime(t.get_text()).strftime('%H:%M:%S') for t in ax.get_xticklabels()])
|
330 |
-
plt.ylabel('Pulse')
|
331 |
-
plt.xlabel('time')
|
332 |
-
plt.savefig(f'/time_series/figure_{num:010d}.png')
|
333 |
-
num += 1
|
334 |
-
except:
|
335 |
-
log_string += f'An error occured while saving figure_{num:010d}.png, '
|
336 |
|
337 |
-
return log_string
|
338 |
|
339 |
|
340 |
@hydra.main(version_base=None, config_path=str(DEFAULT_CONFIG.parent), config_name=DEFAULT_CONFIG.name)
|
@@ -353,10 +353,10 @@ def gradio_wrapper(img):
|
|
353 |
#print(np.shape(img))
|
354 |
return result
|
355 |
demo = gr.Interface(
|
356 |
-
gradio_wrapper,
|
357 |
#gr.Image(source="webcam", streaming=True, flip=True),
|
358 |
-
gr.Image(source="webcam", streaming=True),
|
359 |
-
|
360 |
live=True
|
361 |
)
|
362 |
|
|
|
299 |
|
300 |
outputs = deepsort.update(xywhs, confss, oids, im0)
|
301 |
|
302 |
+
#with open('/pulse.csv', 'a') as f:
|
303 |
# create the csv writer
|
304 |
+
#writer = csv.writer(f)
|
305 |
+
if len(outputs) > 0:
|
306 |
+
bbox_xyxy = outputs[:, :4]
|
307 |
+
identities = outputs[:, -2]
|
308 |
+
object_id = outputs[:, -1]
|
309 |
|
310 |
+
#f2 = open('/vehicles_data.csv', "w+")
|
311 |
+
#f2.close()
|
312 |
+
#with open('/vehicles_data.csv', 'a') as f:
|
313 |
+
#writer2 = csv.writer(f)
|
314 |
+
#header = ['id', 'class', 'speed', 'weight']
|
315 |
+
#writer2.writerow(header)
|
316 |
+
img= draw_boxes(im0, bbox_xyxy, self.model.names, object_id,writer, writer2, identities)
|
317 |
+
#df = pd.read_csv("/pulse.csv")
|
318 |
+
#df['time'] = pd.to_datetime(df['time'], format = '%H:%M:%S %d.%m.%Y')
|
319 |
|
320 |
|
321 |
+
#df.index = df['time']
|
322 |
+
#del df['time']
|
323 |
|
324 |
+
#try:
|
325 |
+
#fig, ax = plt.subplots()
|
326 |
#plt.clf()
|
327 |
+
#sns.lineplot(df)
|
328 |
#ax.set_xticklabels([t.get_text().split(".")[0] for t in ax.get_xticklabels()])
|
329 |
+
#ax.set_xticklabels([pd.to_datetime(t.get_text()).strftime('%H:%M:%S') for t in ax.get_xticklabels()])
|
330 |
+
#plt.ylabel('Pulse')
|
331 |
+
#plt.xlabel('time')
|
332 |
+
#plt.savefig(f'/time_series/figure_{num:010d}.png')
|
333 |
+
#num += 1
|
334 |
+
#except:
|
335 |
+
#log_string += f'An error occured while saving figure_{num:010d}.png, '
|
336 |
|
337 |
+
return log_string, img
|
338 |
|
339 |
|
340 |
@hydra.main(version_base=None, config_path=str(DEFAULT_CONFIG.parent), config_name=DEFAULT_CONFIG.name)
|
|
|
353 |
#print(np.shape(img))
|
354 |
return result
|
355 |
demo = gr.Interface(
|
356 |
+
fn=gradio_wrapper,
|
357 |
#gr.Image(source="webcam", streaming=True, flip=True),
|
358 |
+
inputs=gr.Image(source="webcam", streaming=True),
|
359 |
+
outputs=img, log_string
|
360 |
live=True
|
361 |
)
|
362 |
|