Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,14 +107,33 @@ with row3_col5:
|
|
| 107 |
# Output and Interaction
|
| 108 |
###
|
| 109 |
#####
|
| 110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
st.write("\n\n")
|
| 113 |
components.html("""<hr style="height:2px;border:none;color:#333;background-color:#333;" /> """)
|
| 114 |
|
| 115 |
# model
|
| 116 |
model = YOLO("/home/user/app/models/head_model/best.pt") # load
|
| 117 |
-
results = model.predict(
|
| 118 |
|
| 119 |
|
| 120 |
_, col_1, col_2, _ = st.columns([1, 4, 4, 1], gap="medium")
|
|
|
|
| 107 |
# Output and Interaction
|
| 108 |
###
|
| 109 |
#####
|
| 110 |
+
# Function to break the image into tiles
|
| 111 |
+
def tile_image(image, tile_size, overlap):
|
| 112 |
+
# Get the image size
|
| 113 |
+
width, height = image.size
|
| 114 |
+
|
| 115 |
+
# Create a list to store the tiles
|
| 116 |
+
tiles = []
|
| 117 |
+
|
| 118 |
+
# Loop through the image and break it into tiles
|
| 119 |
+
for x in range(0, width, tile_size - overlap):
|
| 120 |
+
for y in range(0, height, tile_size - overlap):
|
| 121 |
+
# Get the tile
|
| 122 |
+
tile = image.crop((x, y, x + tile_size, y + tile_size))
|
| 123 |
+
tiles.append(tile)
|
| 124 |
+
|
| 125 |
+
return tiles
|
| 126 |
|
| 127 |
+
if st.session_state.image is not None:
|
| 128 |
+
# tile images
|
| 129 |
+
tiles = tile_image(image=st.session_state.image, tile_size=640, overlap=40)
|
| 130 |
+
|
| 131 |
st.write("\n\n")
|
| 132 |
components.html("""<hr style="height:2px;border:none;color:#333;background-color:#333;" /> """)
|
| 133 |
|
| 134 |
# model
|
| 135 |
model = YOLO("/home/user/app/models/head_model/best.pt") # load
|
| 136 |
+
results = model.predict(tiles) # predict
|
| 137 |
|
| 138 |
|
| 139 |
_, col_1, col_2, _ = st.columns([1, 4, 4, 1], gap="medium")
|