[AI] AI 무조건따라해보기02~구글 AI Studio 튜토리얼 만들어보기~()__-미니포지 아나콘다 VS코드 안티그래피티-++
[AI] AI 무조건따라해보기02~구글 AI Studio 튜토리얼 만들어보기~()__-미니포지 아나콘다 VS코드 안티그래피티-++
00. 구글 AI STUDIO 접속
https://ai.google.dev/edge/mediapipe/solutions/vision/image_classifier?hl=ko
01. 이미지 분류 테스크
AI 모델 다운로드 EfficientNet-Lite0 (float 32)
02. Python - 코드 예시 선택
https://colab.research.google.com/github/googlesamples/mediapipe/blob/main/examples/image_classification/python/image_classifier.ipynb?hl=ko#scrollTo=L_cQX8dWu4Dv
0. 모델 폴더 생성 및 다운받은 모델 집어넣기
= dev 안에 -> models 생성
다운받은 파일 이동 models -> efficientnet_lite0
1. 파이썬파일 생성
= proj1 -> cls.py
2. cmd 실행
= pip install mediapipe
3. Visualization utilities
= 여기 코드가 필요할때가있음 여기에서는 필요없음
4. Download test images
= 아래 링크(name부분에 버거.jpg 집어넣고 다운로드. cat.jpg 집어넣고 이미지 다운로드(우클릭 다른이미지로 다운로드)
https://storage.googleapis.com/mediapipe-tasks/image_classifier/{name}
['burger.jpg', 'cat.jpg']
5. 이미지 체크
import cv2
from google.colab.patches import cv2_imshow
import math
DESIRED_HEIGHT = 480
DESIRED_WIDTH = 480
def resize_and_show(image):
h, w = image.shape[:2]
if h < w:
img = cv2.resize(image, (DESIRED_WIDTH, math.floor(h/(w/DESIRED_WIDTH))))
else:
img = cv2.resize(image, (math.floor(w/(h/DESIRED_HEIGHT)), DESIRED_HEIGHT))
cv2_imshow(img)
# Preview the images.
images = {name: cv2.imread(name) for name in IMAGE_FILENAMES}
for name, image in images.items():
print(name)
resize_and_show(image)
/////////////////
-> 아래 소스로 변경 하여 테스트
-> 실행방법 :
IMAGE_FILENAMES = ['burger.jpg', 'cat.jpg']
import cv2
import math
DESIRED_HEIGHT = 480
DESIRED_WIDTH = 480
def resize_and_show(image):
h, w = image.shape[:2]
if h < w:
img = cv2.resize(image, (DESIRED_WIDTH, math.floor(h/(w/DESIRED_WIDTH))))
else:
img = cv2.resize(image, (math.floor(w/(h/DESIRED_HEIGHT)), DESIRED_HEIGHT))
cv2.imshow("test", img)
cv2.waitKey(0)
# # Preview the images.
images = {name: cv2.imread(name) for name in IMAGE_FILENAMES}
for name, image in images.items():
print(name)
resize_and_show(image)
-> 결과
(proj1) C:\Users\301\dev>python proj1/cls.py
burger.jpg
cat.jpg
댓글
댓글 쓰기