docker如何導出指定時間段內(nèi)日志
docker導出指定時間段內(nèi)日志
命令格式如下:
docker logs --since <起始時間> --until <結(jié)束時間> <容器ID或名稱> > <導出文件路徑>
<起始時間>
:指定要導出日志的起始時間,格式為YYYY-MM-DDTHH:MM:SS。<結(jié)束時間>
:指定要導出日志的結(jié)束時間,格式為YYYY-MM-DDTHH:MM:SS。<容器ID或名稱>
:指定要導出日志的Docker容器ID或名稱。<導出文件路徑>
:指定導出日志的文件路徑和文件名。
例如:
要導出容器ID為58c472a20857
的Docker日志,在2023年7月7日00:00:00到2023年7月14日23:59:59之間的日志
可以使用以下命令:
docker logs --since="2023-07-07T00:00:00" --until "2023-07-14T23:59:59" 58c472a20857 > log.txt
目標檢測中遇到的問題和docker導出日志
docker容器導出日志
導出日志在Linux服務器的本地目錄下,可以直接下載
docker logs 容器名稱 > log.txt
Flask使用main執(zhí)行
1 改dockerfile 文件內(nèi)容
#CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"] CMD [ "python", "./app.py" ]
2 改 app.py 中的內(nèi)容
from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return "Hello, World!" if __name__ == '__main__': app.run(host='0.0.0.0')
針對加載模型時間過長
將模型在主程序 main 中加載,進行flask交互時,將全局變量直接導入使用模塊中,比如提前加載YOLOv5模型。
if __name__ == "__main__": os.makedirs("./config/", exist_ok=True) config = Config('config/config.json') print("加載YOLO模型:") # 從本地目錄加載自定義的YOLOv5模型 yolo_model = torch.hub.load('yolov5', 'custom', path='yolov5/best.pt', source='local') # 設置置信度閾值 yolo_model.conf = config.floating_threshold app.run(host='0.0.0.0')
提取圖片中的識別區(qū),將無關部分去除
def adjust_img_size(img, width_ratio=1, height_ratio=0.8, padding_color=(255, 255, 255)): """ 獲取圖片中間長寬各1/2的中間區(qū)域,外部全部填充為指定顏色。 Parameters: img (numpy.ndarray or PIL.Image.Image): 輸入的圖片,可以是numpy數(shù)組或PIL圖像對象。 padding_color (tuple): 填充的顏色,格式為 (R, G, B)。 width_ratio:ratio height_ratio:ratio Returns: numpy.ndarray: 調(diào)整后的圖片數(shù)組。 """ # 將輸入圖片轉(zhuǎn)換為numpy數(shù)組 if isinstance(img, Image.Image): img = np.array(img) # 獲取圖片尺寸 height, width, channels = img.shape # 創(chuàng)建填充區(qū)域 padding = np.full((height, width, channels), padding_color, dtype=np.uint8) # 計算截取的高度和寬度 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) # 截取圖像 cropped_image = img[height_1:crop_height + height_1, width_1:crop_width + width_1] # 將原始圖片放入填充區(qū)域的中間 padding[height_1:crop_height + height_1, width_1:crop_width + width_1] = cropped_image return padding
返回圖片中固定比例的點
def get_point(img, height_ratio, width_ratio): """返回圖片中的點目標點,用于在圖上做標注""" # 獲取圖片尺寸 height, width, channels = img.shape # print('查看形狀:', img.shape) # 計算截取的高度和寬度 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('查看返回值:', width_1, height_1, width_2, height_2) return width_1, height_1, width_2, height_2
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
借助Docker搭建JMeter+Grafana+Influxdb監(jiān)控平臺的詳細教程
這篇文章主要介紹了借助Docker搭建JMeter+Grafana+Influxdb監(jiān)控平臺,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-01-01Docker向數(shù)據(jù)卷Volume寫入數(shù)據(jù)
這篇文章介紹了Docker向數(shù)據(jù)卷Volume寫入數(shù)據(jù)的方法,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-03-03docker打包鏡像后EasyExcel報錯,dockerfile缺少字體的解決
解決Docker打包鏡像后EasyExcel報錯的問題:1. Dockerfile增加字體配置;2. 使用EasyExcel的write時添加"inMemory"參數(shù)為true,開啟內(nèi)存處理模式(不推薦,1W數(shù)據(jù)以內(nèi)可以考慮)2025-02-02