Sergey Mikhno commited on
Commit
089c072
·
1 Parent(s): 5576d76
Files changed (1) hide show
  1. app/app.py +4 -1
app/app.py CHANGED
@@ -1,6 +1,7 @@
1
  from flask import Flask
2
  from doclayout_yolo import YOLOv10
3
  from huggingface_hub import hf_hub_download
 
4
 
5
  import os
6
  import json
@@ -35,11 +36,13 @@ def doc_layout():
35
  if file and allowed_file(file.filename):
36
  filename = "/tmp/" + secure_filename(file.filename)
37
  file.save(filename)
 
 
38
  det_res = model.predict(
39
  filename, # Image to predict
40
  imgsz=1024, # Prediction image size
41
  conf=0.2, # Confidence threshold
42
- device="cuda:0" # Device to use (e.g., 'cuda:0' or 'cpu')
43
  )
44
  names = det_res[0].names
45
  blocknames = [names[int(n)] for n in det_res[0].boxes.cls]
 
1
  from flask import Flask
2
  from doclayout_yolo import YOLOv10
3
  from huggingface_hub import hf_hub_download
4
+ import torch
5
 
6
  import os
7
  import json
 
36
  if file and allowed_file(file.filename):
37
  filename = "/tmp/" + secure_filename(file.filename)
38
  file.save(filename)
39
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
40
+ print(device)
41
  det_res = model.predict(
42
  filename, # Image to predict
43
  imgsz=1024, # Prediction image size
44
  conf=0.2, # Confidence threshold
45
+ device=device
46
  )
47
  names = det_res[0].names
48
  blocknames = [names[int(n)] for n in det_res[0].boxes.cls]