Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
-
|
2 |
-
os.system("pip install -q git+https://github.com/THU-MIG/yolov10.git")
|
3 |
-
os.system("sed -i 's/config.max_workspace_size = self.args.workspace \* 1 << 30/config.set_memory_pool_limit(trt.MemoryPoolType.WORKSPACE, self.args.workspace \* 1 << 30)/' exporter.py")
|
4 |
import gradio as gr
|
5 |
import numpy as np
|
6 |
import fitz # PyMuPDF
|
@@ -9,21 +7,15 @@ from ultralytics import YOLOv10
|
|
9 |
|
10 |
# Load the trained model
|
11 |
|
12 |
-
|
13 |
-
def model_cv():
|
14 |
-
model = YOLOv10("best.pt")
|
15 |
-
|
16 |
-
model.export(format='engine',imgsz=640, iou=0.7, device = 0, simplify=True, half = True)
|
17 |
-
model = YOLOv10('yolov10l.engine', task='detect')
|
18 |
-
return model
|
19 |
|
20 |
-
model = model_cv()
|
21 |
|
22 |
# Define the class indices for figures and tables
|
23 |
figure_class_index = 3 # class index for figures
|
24 |
table_class_index = 4 # class index for tables
|
25 |
|
26 |
# Function to perform inference on an image and return bounding boxes for figures and tables
|
|
|
27 |
def infer_image_and_get_boxes(image, confidence_threshold=0.6):
|
28 |
results = model.predict(image)
|
29 |
boxes = [
|
|
|
1 |
+
|
|
|
|
|
2 |
import gradio as gr
|
3 |
import numpy as np
|
4 |
import fitz # PyMuPDF
|
|
|
7 |
|
8 |
# Load the trained model
|
9 |
|
10 |
+
model = YOLOv10("best.pt")
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
|
|
12 |
|
13 |
# Define the class indices for figures and tables
|
14 |
figure_class_index = 3 # class index for figures
|
15 |
table_class_index = 4 # class index for tables
|
16 |
|
17 |
# Function to perform inference on an image and return bounding boxes for figures and tables
|
18 |
+
@spaces.GPU
|
19 |
def infer_image_and_get_boxes(image, confidence_threshold=0.6):
|
20 |
results = model.predict(image)
|
21 |
boxes = [
|