gutishin

あなたの人生を少し面白く

自作でアプリを作る活動をしています。よかったら遊んでみてください

Guthisin コード勉強メモ

 

FROM python:3.9

WORKDIR /var/www
COPY /requirements /var/www/requirements

COPY /requirements /tmp/requirements

RUN apt -y update && apt -y upgrade
RUN apt -y install libopencv-dev
RUN pip install --upgrade pip
# API関連のライブラリインストール
RUN pip install -r /tmp/requirements/requirements.txt
RUN pip install -r /tmp/requirements/conflict.txt

CMD ["/bin/bash"]

 

docker image build -t prptotype:latest .

 

docker container run -it --name pytorchTest -v ${PWD}/script:/var/www feature/pytorch:latest

 

docker start コンテナ名

 

docker container exec -it コンテナ名 bash


参考サイト

https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/vocab.json

https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/merges.txt
https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/added_tokens.json
https://huggingface.co/openai/openai/clip-vit-large-patch14/resolve/main/special_tokens_map.json
https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/special_tokens_map.json
https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/tokenizer_config.json
https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/config.json
https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/model.safetensors


/root/.cache/huggingface/hub/models--openai--clip-vit-large-patch14/snapshots/32bd64288804d66eefd0ccbe215aa642df71cc41

使ったライブラリを入れた場所

/usr/local/lib/python3.9/site-packages

docker コンテナにフォルダコピー

docker cp /datas pytorchTest2:/root/.cache/huggingface/hub/models--openai--clip-vit-large-patch14/snapshots/32bd64288804d66eefd0ccbe215aa642df71cc41/

 

 

ファイル解析のテストコード

from PIL import Image

import numpy as np
import matplotlib.pyplot as plt

img = np.array(Image.open("test.png").convert('L'))

x= img.reshape(1,315984)[0]

# ヒストグラムを出力
plt.hist(x)

_new = np.where(img < 135, 0, img)
_new = np.where(img >= 135, 1, _new)

one_new = np.ones_like(_new)

filter_img=one_new*255*_new

zeros_new = np.zeros_like(_new)

img_test = np.array(Image.open("test.png"))

RGB = np.dstack*1

rgb_with_filter=Image.fromarray(np.uint8(RGB))

上記のコードを実行すると解析ができる

*1:filter_img, zeros_new, zeros_new