Spaces:
Sleeping
Sleeping
Daniel Cerda Escobar
commited on
Commit
·
e422d92
1
Parent(s):
4c6c8f5
Update files
Browse files
app.py
CHANGED
@@ -100,7 +100,7 @@ with col2:
|
|
100 |
st.markdown('##### Preview')
|
101 |
# visualize input image
|
102 |
if uploaded_file is not None:
|
103 |
-
image_file = convert_pdf_file(path=path)
|
104 |
image = Image.open(image_file)
|
105 |
else:
|
106 |
image = sahi.utils.cv.read_image_as_pil(IMAGE_TO_URL[radio])
|
@@ -163,7 +163,7 @@ with col2:
|
|
163 |
img2=st.session_state["output_2"],
|
164 |
label1='Uploaded Diagram',
|
165 |
label2='Model Inference',
|
166 |
-
width=
|
167 |
starting_position=50,
|
168 |
show_labels=True,
|
169 |
make_responsive=True,
|
|
|
100 |
st.markdown('##### Preview')
|
101 |
# visualize input image
|
102 |
if uploaded_file is not None:
|
103 |
+
#image_file = convert_pdf_file(path=path)
|
104 |
image = Image.open(image_file)
|
105 |
else:
|
106 |
image = sahi.utils.cv.read_image_as_pil(IMAGE_TO_URL[radio])
|
|
|
163 |
img2=st.session_state["output_2"],
|
164 |
label1='Uploaded Diagram',
|
165 |
label2='Model Inference',
|
166 |
+
width=1280,
|
167 |
starting_position=50,
|
168 |
show_labels=True,
|
169 |
make_responsive=True,
|
utils.py
CHANGED
@@ -16,10 +16,7 @@ def sahi_yolov8m_inference(
|
|
16 |
overlap_height_ratio=0.2,
|
17 |
overlap_width_ratio=0.2,
|
18 |
image_size=640,
|
19 |
-
#postprocess_type="GREEDYNMM",
|
20 |
-
#postprocess_match_metric="IOS",
|
21 |
postprocess_match_threshold=0.5,
|
22 |
-
#postprocess_class_agnostic=False,
|
23 |
):
|
24 |
|
25 |
# standard inference
|
@@ -41,10 +38,7 @@ def sahi_yolov8m_inference(
|
|
41 |
slice_width=slice_width,
|
42 |
overlap_height_ratio=overlap_height_ratio,
|
43 |
overlap_width_ratio=overlap_width_ratio,
|
44 |
-
#postprocess_type=postprocess_type,
|
45 |
-
#postprocess_match_metric=postprocess_match_metric,
|
46 |
postprocess_match_threshold=postprocess_match_threshold,
|
47 |
-
#postprocess_class_agnostic=postprocess_class_agnostic,
|
48 |
)
|
49 |
visual_result_2 = sahi.utils.cv.visualize_object_predictions(
|
50 |
image=numpy.array(image),
|
@@ -55,21 +49,21 @@ def sahi_yolov8m_inference(
|
|
55 |
|
56 |
return output_1, output_2
|
57 |
|
58 |
-
def convert_pdf_file(
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
):
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
16 |
overlap_height_ratio=0.2,
|
17 |
overlap_width_ratio=0.2,
|
18 |
image_size=640,
|
|
|
|
|
19 |
postprocess_match_threshold=0.5,
|
|
|
20 |
):
|
21 |
|
22 |
# standard inference
|
|
|
38 |
slice_width=slice_width,
|
39 |
overlap_height_ratio=overlap_height_ratio,
|
40 |
overlap_width_ratio=overlap_width_ratio,
|
|
|
|
|
41 |
postprocess_match_threshold=postprocess_match_threshold,
|
|
|
42 |
)
|
43 |
visual_result_2 = sahi.utils.cv.visualize_object_predictions(
|
44 |
image=numpy.array(image),
|
|
|
49 |
|
50 |
return output_1, output_2
|
51 |
|
52 |
+
# def convert_pdf_file(
|
53 |
+
# path,
|
54 |
+
# #filename=name,
|
55 |
+
# dpi=300,
|
56 |
+
# image_width=4961,
|
57 |
+
# image_heigth=3508,
|
58 |
+
# grayscale=True,
|
59 |
+
# ):
|
60 |
+
# with open(path, 'rb') as pdf_file:
|
61 |
+
# pdf_reader = PyPDF4.PdfFileReader(pdf_file, strict=False)
|
62 |
+
# first_page = pdf_reader.getPage(0)
|
63 |
+
# page_size = (first_page.mediaBox.getWidth(), first_page.mediaBox.getHeight())
|
64 |
+
# if page_size[0] > page_size[1]:
|
65 |
+
# image = convert_from_path(path, dpi=dpi, size=(image_width,image_heigth), grayscale=grayscale)
|
66 |
+
# else:
|
67 |
+
# image = convert_from_path(path, dpi=dpi, size=(image_heigth,image_width), grayscale=grayscale)
|
68 |
+
# return image
|
69 |
+
# image[0].save(f'{path}/{filename}.png', 'PNG')
|