PyTorch의 CocoCaptions (1)
커피 한잔 사주세요😄
*메모:
- 내 게시물에서는 captions_train2014.json, 인스턴스_train2014.json 및 person_keypoints_train2014.json이 있는 train2014, captions_val2014.json, 인스턴스_val2014.json 및 person_keypoints_val2014.json이 있는 val2014 및 image_info_test2014.json이 있는 test2017을 사용하는 CocoDetection()에 대해 설명합니다. image_info_test2015.json 및 image_info_test-dev2015.json.
- 내 게시물에서는 captions_train2017.json, 인스턴스_train2017.json 및 person_keypoints_train2017.json이 포함된 train2017, captions_val2017.json이 포함된 val2017, 인스턴스_val2017.json 및 person_keypoints_val2017.json 및 image_info_test2017.json이 포함된 test2017을 사용하는 CocoDetection()에 대해 설명합니다. image_info_test-dev2017.json.
- 내 게시물에서는 stuff_train2017.json과 함께 train2017, stuff_val2017.json과 함께 val2017, stuff_train2017.json과 함께 stuff_train2017_pixelmaps, stuff_val2017.json과 함께 stuff_val2017_pixelmaps, panoptic_train2017.json과 함께 panoptic_train2017을 사용하는 CocoDetection()에 대해 설명합니다. panoptic_val2017.json이 포함된 panoptic_val2017 및 image_info_unlabeled2017.json이 포함된 unlabeled2017.
- 제 글은 MS COCO에 대한 설명입니다.
CocoCaptions()는 아래와 같이 MS COCO 데이터세트를 사용할 수 있습니다. *이것은 captions_train2014.json, 인스턴스_train2014.json 및 person_keypoints_train2014.json이 포함된 train2014, captions_val2014.json, 인스턴스_val2014.json 및 person_keypoints_val2014.json이 포함된 val2014 및 image_info_test2014.json, image_info_test2015.json이 포함된 test2017 및 image_info_test-dev2015.json:
*메모:
- 첫 번째 인수는 루트(Required-Type:str 또는 pathlib.Path)입니다.
*메모:
- 이미지로 가는 길입니다.
- 절대경로, 상대경로 모두 가능합니다.
- 두 번째 인수는 annFile(Required-Type:str 또는 pathlib.Path)입니다.
*메모:
- 주석으로 가는 길입니다.
- 절대경로, 상대경로 모두 가능합니다.
- 세 번째 인수는 변환(Optional-Default:None-Type:callable)입니다.
- 네 번째 인수는 target_transform(Optional-Default:None-Type:callable)입니다.
- 다섯 번째 인수는 변환(Optional-Default:None-Type:callable)입니다.
from torchvision.datasets import CocoCaptions cap_train2014_data = CocoCaptions( root="data/coco/imgs/train2014", annFile="data/coco/anns/trainval2014/captions_train2014.json" ) cap_train2014_data = CocoCaptions( root="data/coco/imgs/train2014", annFile="data/coco/anns/trainval2014/captions_train2014.json", transform=None, target_transform=None, transforms=None ) ins_train2014_data = CocoCaptions( root="data/coco/imgs/train2014", annFile="data/coco/anns/trainval2014/instances_train2014.json" ) pk_train2014_data = CocoCaptions( root="data/coco/imgs/train2014", annFile="data/coco/anns/trainval2014/person_keypoints_train2014.json" ) len(cap_train2014_data), len(ins_train2014_data), len(pk_train2014_data) # (82783, 82783, 82783) cap_val2014_data = CocoCaptions( root="data/coco/imgs/val2014", annFile="data/coco/anns/trainval2014/captions_val2014.json" ) ins_val2014_data = CocoCaptions( root="data/coco/imgs/val2014", annFile="data/coco/anns/trainval2014/instances_val2014.json" ) pk_val2014_data = CocoCaptions( root="data/coco/imgs/val2014", annFile="data/coco/anns/trainval2014/person_keypoints_val2014.json" ) len(cap_val2014_data), len(ins_val2014_data), len(pk_val2014_data) # (40504, 40504, 40504) test2014_data = CocoCaptions( root="data/coco/imgs/test2014", annFile="data/coco/anns/test2014/image_info_test2014.json" ) test2015_data = CocoCaptions( root="data/coco/imgs/test2015", annFile="data/coco/anns/test2015/image_info_test2015.json" ) testdev2015_data = CocoCaptions( root="data/coco/imgs/test2015", annFile="data/coco/anns/test2015/image_info_test-dev2015.json" ) len(test2014_data), len(test2015_data), len(testdev2015_data) # (40775, 81434, 20288) cap_train2014_data # Dataset CocoCaptions # Number of datapoints: 82783 # Root location: data/coco/imgs/train2014 cap_train2014_data.root # 'data/coco/imgs/train2014' print(cap_train2014_data.transform) # None print(cap_train2014_data.target_transform) # None print(cap_train2014_data.transforms) # None cap_train2014_data.coco # <pycocotools.coco.COCO at 0x759028ee1d00> cap_train2014_data[26] # (<PIL.Image.Image image mode=RGB size=427x640>, # ['three zeebras standing in a grassy field walking', # 'Three zebras are standing in an open field.', # 'Three zebra are walking through the grass of a field.', # 'Three zebras standing on a grassy dirt field.', # 'Three zebras grazing in green grass field area.']) cap_train2014_data[179] # (<PIL.Image.Image image mode=RGB size=480x640>, # ['a young guy walking in a forrest holding an object in his hand', # 'A partially black and white photo of a man throwing ... the woods.', # 'A disc golfer releases a throw from a dirt tee ... wooded course.', # 'The person is in the clearing of a wooded area. ', # 'a person throwing a frisbee at many trees ']) cap_train2014_data[194] # (<PIL.Image.Image image mode=RGB size=428x640>, # ['A person on a court with a tennis racket.', # 'A man that is holding a racquet standing in the grass.', # 'A tennis player hits the ball during a match.', # 'The tennis player is poised to serve a ball.', # 'Man in white playing tennis on a court.']) ins_train2014_data[26] # Error ins_train2014_data[179] # Error ins_train2014_data[194] # Error pk_train2014_data[26] # (<PIL.Image.Image image mode=RGB size=427x640>, []) pk_train2014_data[179] # Error pk_train2014_data[194] # Error cap_val2014_data[26] # (<PIL.Image.Image image mode=RGB size=640x360>, # ['a close up of a child next to a cake with balloons', # 'A baby sitting in front of a cake wearing a tie.', # 'The young boy is dressed in a tie that matches his cake. ', # 'A child eating a birthday cake near some balloons.', # 'A baby eating a cake with a tie around ... the background.']) cap_val2014_data[179] # (<PIL.Image.Image image mode=RGB size=500x302>, # ['Many small children are posing together in the ... white photo. ', # 'A vintage school picture of grade school aged children.', # 'A black and white photo of a group of kids.', # 'A group of children standing next to each other.', # 'A group of children standing and sitting beside each other. ']) cap_val2014_data[194] # (<PIL.Image.Image image mode=RGB size=640x427>, # ['A man hitting a tennis ball with a racquet.', # 'champion tennis player swats at the ball hoping to win', # 'A man is hitting his tennis ball with a recket on the court.', # 'a tennis player on a court with a racket', # 'A professional tennis player hits a ball as fans watch.']) ins_val2014_data[26] # Error ins_val2014_data[179] # Error ins_val2014_data[194] # Error pk_val2014_data[26] # Error pk_val2014_data[179] # Error pk_val2014_data[194] # Error test2014_data[26] # (<PIL.Image.Image image mode=RGB size=640x640>, []) test2014_data[179] # (<PIL.Image.Image image mode=RGB size=640x480>, []) test2014_data[194] # (<PIL.Image.Image image mode=RGB size=640x360>, []) test2015_data[26] # (<PIL.Image.Image image mode=RGB size=640x480>, []) test2015_data[179] # (<PIL.Image.Image image mode=RGB size=640x426>, []) test2015_data[194] # (<PIL.Image.Image image mode=RGB size=640x480>, []) testdev2015_data[26] # (<PIL.Image.Image image mode=RGB size=640x360>, []) testdev2015_data[179] # (<PIL.Image.Image image mode=RGB size=640x480>, []) testdev2015_data[194] # (<PIL.Image.Image image mode=RGB size=640x480>, []) import matplotlib.pyplot as plt from matplotlib.patches import Polygon, Rectangle import numpy as np from pycocotools import mask 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) x_crd = 0.02 for i, axis in zip(ims, axes.ravel()): if data[i][1]: im, anns = data[i] axis.imshow(X=im) y_crd = 0.0 for j, ann in enumerate(iterable=anns): text_list = ann.split() if len(text_list) > 9: text = " ".join(text_list[0:10]) + " ..." else: text = " ".join(text_list) plt.figtext(x=x_crd, y=y_crd, fontsize=10, s=f'{j} : {text}') y_crd -= 0.06 x_crd += 0.325 if i == 2 and file == "val2017": x_crd += 0.06 elif not data[i][1]: im, _ = data[i] axis.imshow(X=im) fig.tight_layout() plt.show() ims = (26, 179, 194) show_images(data=cap_train2014_data, ims=ims, main_title="cap_train2014_data") show_images(data=cap_val2014_data, ims=ims, main_title="cap_val2014_data") show_images(data=test2014_data, ims=ims, main_title="test2014_data") show_images(data=test2015_data, ims=ims, main_title="test2015_data") show_images(data=testdev2015_data, ims=ims, main_title="testdev2015_data")
위 내용은 PyTorch의 CocoCaptions (1)의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

Python은 배우고 사용하기 쉽고 C는 더 강력하지만 복잡합니다. 1. Python Syntax는 간결하며 초보자에게 적합합니다. 동적 타이핑 및 자동 메모리 관리를 사용하면 사용하기 쉽지만 런타임 오류가 발생할 수 있습니다. 2.C는 고성능 응용 프로그램에 적합한 저수준 제어 및 고급 기능을 제공하지만 학습 임계 값이 높고 수동 메모리 및 유형 안전 관리가 필요합니다.

제한된 시간에 Python 학습 효율을 극대화하려면 Python의 DateTime, Time 및 Schedule 모듈을 사용할 수 있습니다. 1. DateTime 모듈은 학습 시간을 기록하고 계획하는 데 사용됩니다. 2. 시간 모듈은 학습과 휴식 시간을 설정하는 데 도움이됩니다. 3. 일정 모듈은 주간 학습 작업을 자동으로 배열합니다.

Python은 개발 효율에서 C보다 낫지 만 C는 실행 성능이 높습니다. 1. Python의 간결한 구문 및 풍부한 라이브러리는 개발 효율성을 향상시킵니다. 2.C의 컴파일 유형 특성 및 하드웨어 제어는 실행 성능을 향상시킵니다. 선택할 때는 프로젝트 요구에 따라 개발 속도 및 실행 효율성을 평가해야합니다.

하루에 2 시간 동안 파이썬을 배우는 것으로 충분합니까? 목표와 학습 방법에 따라 다릅니다. 1) 명확한 학습 계획을 개발, 2) 적절한 학습 자원 및 방법을 선택하고 3) 실습 연습 및 검토 및 통합 연습 및 검토 및 통합,이 기간 동안 Python의 기본 지식과 고급 기능을 점차적으로 마스터 할 수 있습니다.

Python과 C는 각각 고유 한 장점이 있으며 선택은 프로젝트 요구 사항을 기반으로해야합니다. 1) Python은 간결한 구문 및 동적 타이핑으로 인해 빠른 개발 및 데이터 처리에 적합합니다. 2) C는 정적 타이핑 및 수동 메모리 관리로 인해 고성능 및 시스템 프로그래밍에 적합합니다.

Pythonlistsarepartoftsandardlardlibrary, whileraysarenot.listsarebuilt-in, 다재다능하고, 수집 할 수있는 반면, arraysarreprovidedByTearRaymoduledlesscommonlyusedDuetolimitedFunctionality.

파이썬은 자동화, 스크립팅 및 작업 관리가 탁월합니다. 1) 자동화 : 파일 백업은 OS 및 Shutil과 같은 표준 라이브러리를 통해 실현됩니다. 2) 스크립트 쓰기 : PSUTIL 라이브러리를 사용하여 시스템 리소스를 모니터링합니다. 3) 작업 관리 : 일정 라이브러리를 사용하여 작업을 예약하십시오. Python의 사용 편의성과 풍부한 라이브러리 지원으로 인해 이러한 영역에서 선호하는 도구가됩니다.

웹 개발에서 Python의 주요 응용 프로그램에는 Django 및 Flask 프레임 워크 사용, API 개발, 데이터 분석 및 시각화, 머신 러닝 및 AI 및 성능 최적화가 포함됩니다. 1. Django 및 Flask 프레임 워크 : Django는 복잡한 응용 분야의 빠른 개발에 적합하며 플라스크는 소형 또는 고도로 맞춤형 프로젝트에 적합합니다. 2. API 개발 : Flask 또는 DjangorestFramework를 사용하여 RESTFULAPI를 구축하십시오. 3. 데이터 분석 및 시각화 : Python을 사용하여 데이터를 처리하고 웹 인터페이스를 통해 표시합니다. 4. 머신 러닝 및 AI : 파이썬은 지능형 웹 애플리케이션을 구축하는 데 사용됩니다. 5. 성능 최적화 : 비동기 프로그래밍, 캐싱 및 코드를 통해 최적화
