마스크 R-CNN 및 K-Means 클러스터링을 사용하여 이미지에서 대상의 색상 추출
6289 단어 파이썬mask-r-cnnMachineLearning
개요
마스크 R-CNN 및 제공된 학습 된 모델을 사용하여 이미지의 대상 만 RGB 데이터로 추출합니다.
RGB 데이터를 K-Means으로 클러스터링하면 대상의 도미넌트 컬러을 추출 할 수 있습니다.
예
피자(pizza)


Photo by mahyar motebassem on Unsplash

신호기(traffic light)


Photo by Aleksandr Kotlyar on Unsplash

개(dog)



사용법
$ git clone https://github.com/xy-gao/instance-dominant-colors.git
$ cd instance-dominant-colors
$ pip3 install -r requirements.txt
from instance2color import Instance2Color
inst = Instance2Color(image_file='sample_img/pizza.jpg', class_name='pizza', num_of_color=5)
# 指定できるclass_name:
# class_names = ['BG', 'person', 'bicycle', 'car', 'motorcycle', 'airplane',
# 'bus', 'train', 'truck', 'boat', 'traffic light',
# 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird',
# 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear',
# 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
# 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
# 'kite', 'baseball bat', 'baseball glove', 'skateboard',
# 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup',
# 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
# 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',
# 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
# 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote',
# 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster',
# 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
# 'teddy bear', 'hair drier', 'toothbrush']
# 学習済みモデルは初回にダウンロードされる
print(inst.dominant_colors()) # ドミナントカラーのRGBと割合
# [([174, 77, 68], 29.52), ([223, 140, 100], 26.31), ([99, 47, 38], 20.08), ([96, 181, 108], 12.91), ([227, 206, 189], 11.18)]
inst.visualize_pie(output_file='sample_img/pizza_pie_chart.jpg')# 円グラフを描く
inst.visualize_instance(output_file='sample_img/pizza_inst.jpg')# どこが対象物にされたか確認できる
Reference
이 문제에 관하여(마스크 R-CNN 및 K-Means 클러스터링을 사용하여 이미지에서 대상의 색상 추출), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/gao_gao/items/54cfeb30a4828f25237b
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
피자(pizza)


Photo by mahyar motebassem on Unsplash

신호기(traffic light)


Photo by Aleksandr Kotlyar on Unsplash

개(dog)



사용법
$ git clone https://github.com/xy-gao/instance-dominant-colors.git
$ cd instance-dominant-colors
$ pip3 install -r requirements.txt
from instance2color import Instance2Color
inst = Instance2Color(image_file='sample_img/pizza.jpg', class_name='pizza', num_of_color=5)
# 指定できるclass_name:
# class_names = ['BG', 'person', 'bicycle', 'car', 'motorcycle', 'airplane',
# 'bus', 'train', 'truck', 'boat', 'traffic light',
# 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird',
# 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear',
# 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
# 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
# 'kite', 'baseball bat', 'baseball glove', 'skateboard',
# 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup',
# 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
# 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',
# 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
# 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote',
# 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster',
# 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
# 'teddy bear', 'hair drier', 'toothbrush']
# 学習済みモデルは初回にダウンロードされる
print(inst.dominant_colors()) # ドミナントカラーのRGBと割合
# [([174, 77, 68], 29.52), ([223, 140, 100], 26.31), ([99, 47, 38], 20.08), ([96, 181, 108], 12.91), ([227, 206, 189], 11.18)]
inst.visualize_pie(output_file='sample_img/pizza_pie_chart.jpg')# 円グラフを描く
inst.visualize_instance(output_file='sample_img/pizza_inst.jpg')# どこが対象物にされたか確認できる
Reference
이 문제에 관하여(마스크 R-CNN 및 K-Means 클러스터링을 사용하여 이미지에서 대상의 색상 추출), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/gao_gao/items/54cfeb30a4828f25237b
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
$ git clone https://github.com/xy-gao/instance-dominant-colors.git
$ cd instance-dominant-colors
$ pip3 install -r requirements.txt
from instance2color import Instance2Color
inst = Instance2Color(image_file='sample_img/pizza.jpg', class_name='pizza', num_of_color=5)
# 指定できるclass_name:
# class_names = ['BG', 'person', 'bicycle', 'car', 'motorcycle', 'airplane',
# 'bus', 'train', 'truck', 'boat', 'traffic light',
# 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird',
# 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear',
# 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
# 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
# 'kite', 'baseball bat', 'baseball glove', 'skateboard',
# 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup',
# 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
# 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',
# 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
# 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote',
# 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster',
# 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
# 'teddy bear', 'hair drier', 'toothbrush']
# 学習済みモデルは初回にダウンロードされる
print(inst.dominant_colors()) # ドミナントカラーのRGBと割合
# [([174, 77, 68], 29.52), ([223, 140, 100], 26.31), ([99, 47, 38], 20.08), ([96, 181, 108], 12.91), ([227, 206, 189], 11.18)]
inst.visualize_pie(output_file='sample_img/pizza_pie_chart.jpg')# 円グラフを描く
inst.visualize_instance(output_file='sample_img/pizza_inst.jpg')# どこが対象物にされたか確認できる
Reference
이 문제에 관하여(마스크 R-CNN 및 K-Means 클러스터링을 사용하여 이미지에서 대상의 색상 추출), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/gao_gao/items/54cfeb30a4828f25237b텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)