deeplubcut 動画を対象にした点の位置の予測

点のアノテーションの予測

  • 蝿の腹、マウスの脊椎、指の関節など応用範囲が広い。
  • 動画でできてる。デモがある。
  • 動画の特徴量抽出はResNet, mobileNetなど
    • Mobile Netでできるならエッジコンピューティングが視野に入る
    • ラズパイ+GPUみたいな構成

参考リンク

https://github.com/DeepLabCut/DeepLabCut

[Read More]

Using BART (sentence summary model) with hugging face

  • BART is a model for document summarization
  • Derived from the same transformer as BERT
  • Unlike BERT, it has an encoder-decoder structure
    • This is because it is intended for sentence generation

This page shows the steps to run a tutorial on BART.

Procedure

  1. install transformers

Run ``sh pip install transformers

Run summary

2. Run the summary
from transformers import BartTokenizer, BartForConditionalGeneration, BartConfig

model = BartForConditionalGeneration.from_pretrained('facebook/bart-large')
tokenizer = BartTokenizer.from_pretrained('facebook/bart-large')

ARTICLE_TO_SUMMARIZE = "My friends are cool but they eat too many carbs."
inputs = tokenizer([ARTICLE_TO_SUMMARIZE], max_length=1024, return_tensors='pt')

# Generate Summary
summary_ids = model.generate(inputs['input_ids'], num_beams=4, max_length=5, early_stopping=True)
print([tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=False) for g in summary_ids])
```

On 2021/01/18, the output was MyMy friends.

Interesting.

## Where I got stuck.
Error when the version of pytorch is different from the one specified in transformers.

pip install -U torch

[Read More]

python でのmlflowの使い方

python でmlflow使うメモ

実験結果を比較するために便利っぽいのでmlflow を使ってみた。

パラメータと実験結果の記録をある程度自動化できる。

機械学習の実践はある種の黒魔術となることが多いので再現性を担保するための努力は後々に影響する。

[Read More]

Procedure for obtaining a distributed representation of a Japanese sentence using a trained Universal Sentence Encoder

.

A vector of documents can be obtained using Universal Sentence Encoder.

Features

Supports multiple languages.

Japanese is supported.

Can handle Japanese sentences as vectors.

Usage

Clustering, similarity calculation, feature extraction.

Usage

Execute the following command as preparation.

pip install tensorflow tensorflow_hub tensorflow_text numpy   

Trained models are available.

See the python description below for details on how to use it.

import tensorflow_hub as hub  
import tensorflow_text
import numpy as np  
# for avoiding error  
import ssl  
ssl._create_default_https_context = ssl._create_unverified_context  

def cos_sim(v1, v2):  
   return np.dot(v1, v2) / (np.linalg.norm(v1) * np.linalg.norm(v2))  
  
embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder-multilingual/3")  
  
texts = ["I saw a comedy show yesterday." , "There was a comedy show on TV last night." , "I went to the park yesterday." , "I saw a comedy show last night.", "Yesterday, I went to the park."]  
vectors = embed(texts)  
```.

See the following link for more details

[Try Universal Sentence Encoder in Japanese](https://qiita.com/kenta1984/items/9613da23766a2578a27a)


### Postscript
```py
import tensorflow_text

Without this line, you will get an error like ``Sentencepiece not found! error. This line is not explicitly used in the sample source, but is required for the actual execution. This line is not explicitly used in the sample source, but is required in the actual runtime.

[Read More]

word2vecのアルゴリズムを把握するためにnotebookで動かしながら挙動を理解しよう

word2vecを理解しよう!

  • word2vec のアルゴリズムについて、勉強しようとして苦戦していませんか?
    • アルゴリズムの基になる発想は意外に直観的なものですが、その直観をアルゴリズムの記述から読み取るのはコツが要るかもしれません。
    • 実際に動くモデルで遊んでみて、反応をみながら感覚を掴むといいと思います。
    • 一行単位で実行できるプログラムを自分の手で動かしながら、出力を確認できると分かりやすいと思いませんか?

環境構築不要!

  • そこでGoogle Colaboratory というサービスを利用して、手軽にword2vecを動かして、アルゴリズムの仕組みを理解しましょう!
    • Google Colaboratory はGoogleが提供しているサービスです。
    • Gmailのアカウントを持っていれば環境構築の手間が省け、Googleの計算資源を利用できるものです。
  • そこでword2vecを動かせるプログラムを用意しました。
  • このプログラムは技術書典というイベントで頒布させていただき、50以上の方に利用していただきました。

購入は以下のリンクから

A note on how to use BERT learned from Japanese Wikipedia, now available

huggingface has released a Japanese model for BERT.

The Japanese model is included in transformers.

However, I stumbled over a few things before I could get it to actually work in a Mac environment, so I’ll leave a note.

Preliminaries: Installing mecab

The morphological analysis engine, mecab, is required to use BERT’s Japanese model.

The tokenizer will probably ask for mecab.

This time, we will use homebrew to install Mecab and ipadic.

[Read More]