Segizu commited on
Commit
daa16ff
1 Parent(s): 456adb5
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -6,8 +6,26 @@ import tempfile
6
  import torch
7
 
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
9
- # Cargar el modelo de detecci贸n de objetos usando CPU
10
- detector = pipeline("object-detection", model="facebook/detr-resnet-50").to(device)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  def process_video(video_path):
13
  """
 
6
  import torch
7
 
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
9
+ print(f"Using device: {device}")
10
+
11
+ # Cargar el modelo de detecci贸n de objetos
12
+ try:
13
+ detector = pipeline(
14
+ "object-detection",
15
+ model="facebook/detr-resnet-50",
16
+ device=0 if device == "cuda" else -1, # 0 para GPU, -1 para CPU
17
+ framework="pt" # Especificar PyTorch como framework
18
+ )
19
+ print("Model loaded successfully on", device)
20
+ except Exception as e:
21
+ print(f"Error loading model: {e}")
22
+ print("Falling back to CPU")
23
+ detector = pipeline(
24
+ "object-detection",
25
+ model="facebook/detr-resnet-50",
26
+ device=-1,
27
+ framework="pt"
28
+ )
29
 
30
  def process_video(video_path):
31
  """