panda1835 commited on
Commit
346c324
·
1 Parent(s): 48f78b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -20
app.py CHANGED
@@ -5,6 +5,7 @@ import pandas as pd
5
  import torch
6
  import json
7
  from ultralytics import YOLO
 
8
 
9
  print(f"Is CUDA available: {torch.cuda.is_available()}")
10
  # print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
@@ -14,26 +15,31 @@ print(f"Is CUDA available: {torch.cuda.is_available()}")
14
  detect_model = YOLO('yolov8m_2023-10-23_best.pt')
15
 
16
  def detect(image):
17
- results = detect_model(image, conf=0.1)
18
- try:
19
- results = results[0].boxes.xyxy[0].cpu().numpy()
20
- top = int(results[1])
21
- left = int(results[0])
22
- width = int(results[2] - results[0])
23
- height = int(results[3] - results[1])
24
- return {
25
- "top": top,
26
- "left": left,
27
- "width": width,
28
- "height": height
29
- }
30
- except:
31
- return {
32
- "top": 0,
33
- "left": 0,
34
- "width": 0,
35
- "height": 0
36
- }
 
 
 
 
 
37
 
38
  title = "🐢"
39
 
 
5
  import torch
6
  import json
7
  from ultralytics import YOLO
8
+ from datetime import datetime
9
 
10
  print(f"Is CUDA available: {torch.cuda.is_available()}")
11
  # print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
 
15
  detect_model = YOLO('yolov8m_2023-10-23_best.pt')
16
 
17
  def detect(image):
18
+ results = detect_model(image, conf=0.1)
19
+ # Get the current time
20
+ current_time = datetime.now()
21
+ # Format the current time as a string
22
+ formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S")
23
+ print(formatted_time)
24
+ try:
25
+ results = results[0].boxes.xyxy[0].cpu().numpy()
26
+ top = int(results[1])
27
+ left = int(results[0])
28
+ width = int(results[2] - results[0])
29
+ height = int(results[3] - results[1])
30
+ return {
31
+ "top": top,
32
+ "left": left,
33
+ "width": width,
34
+ "height": height
35
+ }
36
+ except:
37
+ return {
38
+ "top": 0,
39
+ "left": 0,
40
+ "width": 0,
41
+ "height": 0
42
+ }
43
 
44
  title = "🐢"
45