![](/img/trans.png)
[英]Where are images saved when creating images with Pillow in Python
[英]Save images using Pillow without overwriting already saved images
我想保存從特定代碼生成的大約 12000 張圖像。 我將只能使用我的 Project VPN 保存這些圖像,該 VPN 會不斷斷開連接,然后通過覆蓋已保存的圖像並再次花費大量時間來完成整個保存過程。
我如何避免這種情況?
from PIL import Image
dirc = os.path.join(r"C:\\", "DATASET", "Images", f"{measurename}")
if not os.path.exists(dirc):
os.makedirs(dirc)
gray_image_cropped.save(os.path.join(dirc, f"{id}_seg{obj}.tif"))
檢查文件是否存在:
from PIL import Image
dirc = os.path.join(r"C:\\", "DATASET", "Images", f"{measurename}")
if not os.path.exists(dirc):
os.makedirs(dirc)
outfile = os.path.join(dirc, f"{id}_seg{obj}.tif"
if not os.path.exists(outfile):
gray_image_cropped.save(outfile))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.