Docker exports logs within a specified time period
The command format is as follows:
docker logs --since <Start time> --until <End time> <containerIDOr name> > <Export file path>
-
<Start time>
: Specifies the start time of the log to be exported, the format is YYYY-MM-DDTHH:MM:SS. -
<End Time>
: Specifies the end time of the log to be exported, the format is YYYY-MM-DDTHH:MM:SS. -
<Container ID or Name>
: Specifies the Docker container ID or name to export the log. -
<Export file path>
: Specify the file path and file name of the export log.
For example:
To export the container ID is58c472a20857
Docker logs, logs between 00:00:00 on July 7, 2023 and 23:59:59 on July 14, 2023
The following commands can be used:
docker logs --since="2023-07-07T00:00:00" --until "2023-07-14T23:59:59" 58c472a20857 >
Issues encountered in object detection and docker export logs
docker container export log
Export logs are in the local directory of the Linux server and can be downloaded directly
docker logs Container name >
Flask uses main execution
1 Change the content of the dockerfile file
#CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"] CMD [ "python", "./" ]
2. Change content
from flask import Flask app = Flask(__name__) @('/') def hello(): return "Hello, World!" if __name__ == '__main__': (host='0.0.0.0')
For too long loading the model
Load the model in the main program main and when performing flask interaction, import global variables directly into the usage module, such as loading the YOLOv5 model in advance.
if __name__ == "__main__": ("./config/", exist_ok=True) config = Config('config/') print("Loading YOLO model:") # Load a custom YOLOv5 model from a local directory yolo_model = ('yolov5', 'custom', path='yolov5/', source='local') # Set confidence threshold yolo_model.conf = config.floating_threshold (host='0.0.0.0')
Extract the recognition area in the picture and remove the irrelevant parts.
def adjust_img_size(img, width_ratio=1, height_ratio=0.8, padding_color=(255, 255, 255)): """ Get the length and width of the picture in the middle1/2The middle area,All external fills to the specified color。 Parameters: img ( or ): Image entered,Can benumpyarray orPILImage object。 padding_color (tuple): Fill color,The format is (R, G, B)。 width_ratio:ratio height_ratio:ratio Returns: : Adjusted image array。 """ # Convert input image to numpy array if isinstance(img, ): img = (img) # Get image size height, width, channels = # Create a fill area padding = ((height, width, channels), padding_color, dtype=np.uint8) # Calculate the intercepted height and width crop_height = int(height * height_ratio) crop_width = int(width * width_ratio) height_1 = int((height - crop_height)*0.5) width_1 = int((width - crop_width) * 0.5) # Snippet the image cropped_image = img[height_1:crop_height + height_1, width_1:crop_width + width_1] # Put the original image in the middle of the filled area padding[height_1:crop_height + height_1, width_1:crop_width + width_1] = cropped_image return padding
Return to the fixed proportion point in the picture
def get_point(img, height_ratio, width_ratio): """Return to the point and target points in the picture, used to mark the picture""" # Get image size height, width, channels = # print('View shape:', ) # Calculate the intercepted height and width crop_height = int(height * height_ratio) crop_width = int(width * width_ratio) height_1 = int((height - crop_height)) width_1 = int((width - crop_width) * 0.5) width_2 = width - width_1 height_2 = height - int((height - crop_height) * 0.5) # print('View return value:', width_1, height_1, width_2, height_2) return width_1, height_1, width_2, height_2
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.