這篇文章示範如何使用 CocoCaptions
庫中的 torchvision.datasets
類別和各種 MS COCO 資料集。 這些範例說明了載入和顯示 unlabeled2017
子集中的圖片。 但是,嘗試存取 stuff_train2017
、stuff_val2017
、stuff_train2017_pixelmaps
和 stuff_val2017_pixelmaps
中的資料會導致錯誤,表示與 CocoCaptions
不相容。 下面提供了程式碼片段及其輸出。
程式碼與輸出:
程式碼嘗試使用 CocoCaptions
載入和利用 MS COCO 資料集的不同子集。 unlabeled2017
子集成功載入並允許圖片顯示。 其他子集(包含「stuff」和「panoptic」資料)會導致錯誤,突出顯示使用 CocoCaptions
與這些特定資料結構的限制。
from torchvision.datasets import CocoCaptions import matplotlib.pyplot as plt # ... (CocoCaptions instantiation code as provided in the input) ... # ... (len() calls and error handling code as provided in the input) ... unlabeled2017_data[2] # Displays image and empty caption list unlabeled2017_data[47] # Displays image and empty caption list unlabeled2017_data[64] # Displays image and empty caption list def show_images(data, ims, main_title=None): file = data.root.split('/')[-1] fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(14, 8)) fig.suptitle(t=main_title, y=0.9, fontsize=14) for i, axis in zip(ims, axes.ravel()): if not data[i][1]: im, _ = data[i] axis.imshow(X=im) fig.tight_layout() plt.show() ims = (2, 47, 64) show_images(data=unlabeled2017_data, ims=ims, main_title="unlabeled2017_data")
show_images
函數顯示 unlabeled2017_data
子集中的三張影像。
結論:
此實驗表明,雖然 CocoCaptions
適用於某些 MS COCO 資料子集(如 unlabeled2017
),但它並不直接與所有註釋相容。 遇到的錯誤表示「stuff」和「panoptic」註解需要不同的方法或不同的資料集類別才能正確載入和使用。 要成功存取數據,需要進一步研究這些註釋的結構和可用的 torchvision
資料集類別。
以上是PyTorch 中的 CocoCaptions (3)的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Python是解釋型語言,但也包含編譯過程。 1)Python代碼先編譯成字節碼。 2)字節碼由Python虛擬機解釋執行。 3)這種混合機制使Python既靈活又高效,但執行速度不如完全編譯型語言。

UseeAforloopWheniteratingOveraseQuenceOrforAspecificnumberoftimes; useAwhiLeLoopWhenconTinuingUntilAcIntiment.forloopsareIdealForkNownsences,而WhileLeleLeleLeleLeleLoopSituationSituationsItuationsItuationSuationSituationswithUndEtermentersitations。

pythonloopscanleadtoerrorslikeinfiniteloops,modifyingListsDuringteritation,逐個偏置,零indexingissues,andnestedloopineflinefficiencies

forloopsareadvantageousforknowniterations and sequests,供應模擬性和可讀性;而LileLoopSareIdealFordyNamicConcitionSandunknowniterations,提供ControloperRoverTermination.1)forloopsareperfectForeTectForeTerToratingOrtratingRiteratingOrtratingRitterlistlistslists,callings conspass,calplace,cal,ofstrings ofstrings,orstrings,orstrings,orstrings ofcces

pythonisehybridmodeLofCompilation和interpretation:1)thepythoninterpretercompilesourcecececodeintoplatform- interpententbybytecode.2)thepythonvirtualmachine(pvm)thenexecutecutestestestestestesthisbytecode,ballancingEaseofuseEfuseWithPerformance。

pythonisbothinterpretedAndCompiled.1)它的compiledTobyTecodeForportabilityAcrosplatforms.2)bytecodeisthenInterpreted,允許fordingfordforderynamictynamictymictymictymictyandrapiddefupment,儘管Ititmaybeslowerthananeflowerthanancompiledcompiledlanguages。

在您的知識之際,而foroopsareideal insinAdvance中,而WhileLoopSareBetterForsituations則youneedtoloopuntilaconditionismet

ForboopSareSusedwhenthentheneMberofiterationsiskNownInAdvance,而WhileLoopSareSareDestrationsDepportonAcondition.1)ForloopSareIdealForiteratingOverSequencesLikelistSorarrays.2)whileLeleLooleSuitableApeableableableableableableforscenarioscenarioswhereTheLeTheLeTheLeTeLoopContinusunuesuntilaspecificiccificcificCondond


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

Dreamweaver CS6
視覺化網頁開發工具

WebStorm Mac版
好用的JavaScript開發工具

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),