찾다

PyTorch의 Caltech

Dec 12, 2024 am 10:27 AM

커피 한잔 사주세요😄

*내 게시물은 Caltech 101에 대해 설명합니다.

Caltech101()은 아래와 같이 Caltech 101 데이터 세트를 사용할 수 있습니다.

*메모:

  • 첫 번째 인수는 루트(필수 유형:str 또는 pathlib.Path)입니다. *절대경로, 상대경로 모두 가능합니다.
  • 두 번째 인수는 target_type(Optional-Default:"category"-Type:str 또는 튜플 또는 str 목록)입니다. *메모:
    • "카테고리" 및/또는 "주석"을 설정할 수 있습니다.
    • 101개 카테고리(클래스)의 라벨 및/또는 주석이 포함된 8.677개의 이미지가 반환됩니다.
  • 세 번째 인수는 변환(Optional-Default:None-Type:callable)입니다.
  • 네 번째 인수는 target_transform(Optional-Default:None-Type:callable)입니다.
  • 다섯 번째 인수는 download(Optional-Default:False-Type:bool)입니다. *메모:
    • True인 경우 데이터 세트가 인터넷에서 다운로드되어 루트에 추출(압축 해제)됩니다.
    • True이고 데이터세트가 이미 다운로드된 경우 추출됩니다.
    • True이고 데이터 세트가 이미 다운로드되어 추출된 경우 아무 일도 일어나지 않습니다.
    • 데이터 세트가 이미 다운로드되어 추출된 경우 더 빠르므로 False여야 합니다.
    • 데이터 세트를 다운로드하려면 gdown이 필요합니다.
    • 여기에서 데이터 세트(101_ObjectCategories.tar.gz 및 Annotations.tar)를 data/caltech101/에 수동으로 다운로드하고 추출할 수 있습니다.
  • 이미지 인덱스의 카테고리(레이블)는 Faces(0)는 0~434, Faces_easy(1)은 435~869, Leopards(2)는 870~1069이고, 오토바이(3)는 1070~1867, 아코디언(4)은 1868~1922, 비행기(5)는 1923~2722, 앵커(6)은 2723~2764, ant(7)은 2765~2806, barrel(8)은 2807~2853, bass(9)는 2854~2907 등 .
from torchvision.datasets import Caltech101

category_data = Caltech101(
    root="data"
)

category_data = Caltech101(
    root="data",
    target_type="category",
    transform=None,
    target_transform=None,
    download=False
)

annotation_data = Caltech101(
    root="data",
    target_type="annotation"
)

all_data = Caltech101(
    root="data",
    target_type=["category", "annotation"]
)

len(category_data), len(annotation_data), len(all_data)
# (8677, 8677, 8677)

category_data
# Dataset Caltech101
#     Number of datapoints: 8677
#     Root location: data\caltech101
#     Target type: ['category']

category_data.root
# 'data/caltech101'

category_data.target_type
# ['category']

print(category_data.transform)
# None

print(category_data.target_transform)
# None

category_data.download
# <bound method caltech101.download of dataset caltech101 number datapoints: root location: data target type:>

len(category_data.categories)
# 101

category_data.categories
# ['Faces', 'Faces_easy', 'Leopards', 'Motorbikes', 'accordion', 
#  'airplanes', 'anchor', 'ant', 'barrel', 'bass', 'beaver',
#  'binocular', 'bonsai', 'brain', 'brontosaurus', 'buddha',
#  'butterfly', 'camera', 'cannon', 'car_side', 'ceiling_fan',
#  'cellphone', 'chair', 'chandelier', 'cougar_body', 'cougar_face', ...]

len(category_data.annotation_categories)
# 101

category_data.annotation_categories
# ['Faces_2', 'Faces_3', 'Leopards', 'Motorbikes_16', 'accordion',
#  'Airplanes_Side_2', 'anchor', 'ant', 'barrel', 'bass',
#  'beaver', 'binocular', 'bonsai', 'brain', 'brontosaurus',
#  'buddha', 'butterfly', 'camera', 'cannon', 'car_side',
#  'ceiling_fan', 'cellphone', 'chair', 'chandelier', 'cougar_body', ...]

category_data[0]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="510x337">, 0)

category_data[1]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="519x343">, 0)

category_data[2]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="492x325">, 0)

category_data[435]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="290x334">, 1)

category_data[870]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="192x128">, 2)

annotation_data[0]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="510x337">,
#  array([[10.00958466, 8.18210863, 8.18210863, 10.92332268, ...],
#         [132.30670927, 120.42811502, 103.52396166, 90.73162939, ...]]))

annotation_data[1]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="519x343">,
#  array([[15.19298246, 13.71929825, 15.19298246, 19.61403509, ...],
#         [121.5877193, 103.90350877, 80.81578947, 64.11403509, ...]]))

annotation_data[2]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="492x325">,
#  array([[10.40789474, 7.17807018, 5.79385965, 9.02368421, ...],
#         [131.30789474, 120.69561404, 102.23947368, 86.09035088, ...]]))

annotation_data[435]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="290x334">,
#  array([[64.52631579, 95.31578947, 123.26315789, 149.31578947, ...],
#         [15.42105263, 8.31578947, 10.21052632, 28.21052632, ...]]))

annotation_data[870]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="192x128">,
#  array([[2.96536524, 7.55604534, 19.45780856, 33.73992443, ...],
#         [23.63413098, 32.13539043, 33.83564232, 8.84193955, ...]]))

all_data[0]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="510x337">,
#  (0, array([[10.00958466, 8.18210863, 8.18210863, 10.92332268, ...],
#             [132.30670927, 120.42811502, 103.52396166, 90.73162939, ...]]))

all_data[1]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="519x343">,
#  (0, array([[15.19298246, 13.71929825, 15.19298246, 19.61403509, ...],
#             [121.5877193, 103.90350877, 80.81578947, 64.11403509, ...]]))

all_data[2]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="492x325">,
#  (0, array([[10.40789474, 7.17807018, 5.79385965, 9.02368421, ...],
#             [131.30789474, 120.69561404, 102.23947368, 86.09035088, ...]]))

all_data[3]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="538x355">,
#  (0, array([[19.54035088, 18.57894737, 26.27017544, 38.2877193, ...],
#             [131.49122807, 100.24561404, 74.2877193, 49.29122807, ...]]))

all_data[4]
# (<pil.jpegimageplugin.jpegimagefile image mode="RGB" size="528x349">,
#  (0, array([[11.87982456, 11.87982456, 13.86578947, 15.35526316, ...],
#             [128.34649123, 105.50789474, 91.60614035, 76.71140351, ...]]))

import matplotlib.pyplot as plt

def show_images(data, main_title=None):
    plt.figure(figsize=(10, 5))
    plt.suptitle(t=main_title, y=1.0, fontsize=14)
    ims = (0, 1, 2, 435, 870, 1070, 1868, 1923, 2723, 2765, 2807, 2854)
    for i, j in enumerate(ims, start=1):
        plt.subplot(2, 5, i)
        if len(data.target_type) == 1:
            if data.target_type[0] == "category":
                im, lab = data[j]
                plt.title(label=lab)
            elif data.target_type[0] == "annotation":
                im, (px, py) = data[j]
                plt.scatter(x=px, y=py)
            plt.imshow(X=im)
        elif len(data.target_type) == 2:
            if data.target_type[0] == "category":
                im, (lab, (px, py)) = data[j]
            elif data.target_type[0] == "annotation":
                im, ((px, py), lab) = data[j]
            plt.title(label=lab)
            plt.imshow(X=im)
            plt.scatter(x=px, y=py)
        if i == 10:
            break
    plt.tight_layout()
    plt.show()

show_images(data=category_data, main_title="category_data")
show_images(data=annotation_data, main_title="annotation_data")
show_images(data=all_data, main_title="all_data")
</pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></pil.jpegimageplugin.jpegimagefile></bound>

Caltech in PyTorch

Caltech in PyTorch

Caltech in PyTorch

위 내용은 PyTorch의 Caltech의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
파이썬에서 두 목록을 연결하는 대안은 무엇입니까?파이썬에서 두 목록을 연결하는 대안은 무엇입니까?May 09, 2025 am 12:16 AM

Python에는 두 개의 목록을 연결하는 방법이 많이 있습니다. 1. 연산자 사용 간단하지만 큰 목록에서는 비효율적입니다. 2. 효율적이지만 원래 목록을 수정하는 확장 방법을 사용하십시오. 3. 효율적이고 읽기 쉬운 = 연산자를 사용하십시오. 4. 메모리 효율적이지만 추가 가져 오기가 필요한 itertools.chain function을 사용하십시오. 5. 우아하지만 너무 복잡 할 수있는 목록 구문 분석을 사용하십시오. 선택 방법은 코드 컨텍스트 및 요구 사항을 기반으로해야합니다.

파이썬 : 두 목록을 병합하는 효율적인 방법파이썬 : 두 목록을 병합하는 효율적인 방법May 09, 2025 am 12:15 AM

Python 목록을 병합하는 방법에는 여러 가지가 있습니다. 1. 단순하지만 큰 목록에 대한 메모리 효율적이지 않은 연산자 사용; 2. 효율적이지만 원래 목록을 수정하는 확장 방법을 사용하십시오. 3. 큰 데이터 세트에 적합한 itertools.chain을 사용하십시오. 4. 사용 * 운영자, 한 줄의 코드로 중소형 목록을 병합하십시오. 5. Numpy.concatenate를 사용하십시오. 이는 고성능 요구 사항이있는 대규모 데이터 세트 및 시나리오에 적합합니다. 6. 작은 목록에 적합하지만 비효율적 인 Append Method를 사용하십시오. 메소드를 선택할 때는 목록 크기 및 응용 프로그램 시나리오를 고려해야합니다.

편집 된 vs 해석 언어 : 장단점편집 된 vs 해석 언어 : 장단점May 09, 2025 am 12:06 AM

CompiledLanguagesOfferSpeedSecurity, while InterpretedLanguagesProvideeaseofusEandportability

파이썬 : 가장 완전한 가이드 인 루프를 위해파이썬 : 가장 완전한 가이드 인 루프를 위해May 09, 2025 am 12:05 AM

Python에서, for 루프는 반복 가능한 물체를 가로 지르는 데 사용되며, 조건이 충족 될 때 반복적으로 작업을 수행하는 데 사용됩니다. 1) 루프 예제 : 목록을 가로 지르고 요소를 인쇄하십시오. 2) 루프 예제 : 올바르게 추측 할 때까지 숫자 게임을 추측하십시오. 마스터 링 사이클 원리 및 최적화 기술은 코드 효율성과 안정성을 향상시킬 수 있습니다.

Python은 문자열로 나열됩니다Python은 문자열로 나열됩니다May 09, 2025 am 12:02 AM

목록을 문자열로 연결하려면 Python의 join () 메소드를 사용하는 것이 최선의 선택입니다. 1) join () 메소드를 사용하여 목록 요소를 ''.join (my_list)과 같은 문자열로 연결하십시오. 2) 숫자가 포함 된 목록의 경우 연결하기 전에 맵 (str, 숫자)을 문자열로 변환하십시오. 3) ','. join (f '({fruit})'forfruitinfruits와 같은 복잡한 형식에 발전기 표현식을 사용할 수 있습니다. 4) 혼합 데이터 유형을 처리 할 때 MAP (str, mixed_list)를 사용하여 모든 요소를 ​​문자열로 변환 할 수 있도록하십시오. 5) 큰 목록의 경우 ''.join (large_li

Python의 하이브리드 접근법 : 컴파일 및 해석 결합Python의 하이브리드 접근법 : 컴파일 및 해석 결합May 08, 2025 am 12:16 AM

PythonuseSahybrideactroach, combingingcompytobytecodeandingretation.1) codeiscompiledToplatform-IndependentBecode.2) bytecodeistredbythepythonvirtonmachine, enterancingefficiency andportability.

Python 's 'for'와 'whind'루프의 차이점을 배우십시오Python 's 'for'와 'whind'루프의 차이점을 배우십시오May 08, 2025 am 12:11 AM

"for"and "while"loopsare : 1) "에 대한"loopsareIdealforitertatingOverSorkNowniterations, whide2) "weekepindiTeRations.Un

Python Concatenate는 중복과 함께 목록입니다Python Concatenate는 중복과 함께 목록입니다May 08, 2025 am 12:09 AM

Python에서는 다양한 방법을 통해 목록을 연결하고 중복 요소를 관리 할 수 ​​있습니다. 1) 연산자를 사용하거나 ()을 사용하여 모든 중복 요소를 유지합니다. 2) 세트로 변환 한 다음 모든 중복 요소를 제거하기 위해 목록으로 돌아가지 만 원래 순서는 손실됩니다. 3) 루프 또는 목록 이해를 사용하여 세트를 결합하여 중복 요소를 제거하고 원래 순서를 유지하십시오.

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

Video Face Swap

Video Face Swap

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

뜨거운 도구

SublimeText3 Linux 새 버전

SublimeText3 Linux 새 버전

SublimeText3 Linux 최신 버전

WebStorm Mac 버전

WebStorm Mac 버전

유용한 JavaScript 개발 도구

ZendStudio 13.5.1 맥

ZendStudio 13.5.1 맥

강력한 PHP 통합 개발 환경

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

SublimeText3 중국어 버전

SublimeText3 중국어 버전

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