본문 바로가기

분류 전체보기112

MASK RCNN 실행시 버전오류 https://github.com/matterport/Mask_RCNN matterport/Mask_RCNN Mask R-CNN for object detection and instance segmentation on Keras and TensorFlow - matterport/Mask_RCNN github.com MASK RCNN에서 실습을 위해 위 레포를 클론하였습니다. 환경은 Colab입니다. 코랩에서 git clone을 했을때의 화면입니다. 루트 디렉토리를 코랩환경에 맞게 다시 설정해주어야 합니다. 루트디렉토리가 맞지 않으면 모듈을 불러올 수 없습니다. 모델을 객체화하는데 문제가 생겼습니다. tensorflow에는 log라는 속성이 없습니다. 1년전에 작성된 레포이기때문에 버전문제라고 짐작할 수 .. 2021. 4. 20.
Self-Attention과 Masked Self-Attention Self-Attention Self attention에서는 Query, Key, Value가 중요한 키워드가 됩니다. 벡터화된 문장을 합쳐 X로 만들고 가중치 Wq, Wk, Wv와 내적하여 각각 Query와 Key, Value값을 도출합니다. 그럼 이렇게 각 토큰에 해당하는 X, Query, Key, Value값이 나타나게됩니다. 이 값을 Query*$Key^T$해줍니다. 말그대로 키 값을 통해서 각 토큰별로 어느정도 연관성이 있는지 알기위함입니다. 이렇게 스코어를 계산하고, 이 값을 softmax함수에 넣어 총합이 1이되게 나누어줍니다. 연관성이 클 수록 값이 커질 것 입니다. 이렇게 softmax까지 한 뒤에, Value값을 곱하고 더해주면 값이 하나 나오게됩니다. 위의 그림에서 "I"를 통해보면, .. 2021. 4. 15.
Attention과 장기 의존성 Seq2Seq(RNN과 장기의존성) RNN을 기반으로한 seq2seq 모델은 encoder에서 input을 받아 고정된 크기의 벡터인 Context Vector를 만들어 냅니다. decoder는 이를 통해서 output을 만들었습니다. 순차적으로 출력하게됩니다. 하지만 크게 두 가지 문제가 있었습니다. Context Vector에 한 문장을 벡터로 표현하다보니 정보의 손실이 많이 발생합니다. 둘째로는 기울기의 소실 문제가 존재합니다. 순차적으로 입력되는 RNN 특성상 decoder로 들어가는 Context Vector는 시퀀스 뒤쪽의 영향을 더 많이 받을 수 밖에 없습니다. 특히 문장이 길어지면 시퀀스 앞쪽에 있는 단어의 영향이 거의 사라집니다. 즉, 문장이 길면 품질이 매우 떨어집니다. 이렇게 이전의 .. 2021. 4. 15.
[CODE] EfficientNetB7 5.EfficientNetB7 ## Import import numpy as np import tensorflow as tf from tensorflow.keras.datasets import cifar100 from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Flatten from tensorflow.keras.layers import Conv2D, MaxPooling2D, BatchNormalization from tensorflow.keras.utils import to_categorical from tensorflow.keras.preprocessing.image impor.. 2021. 4. 10.
[CODE] VGG19 4. VGG19 ## import import numpy as np import keras import tensorflow as tf from tensorflow.keras.datasets import cifar100 from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Dropout, Flatten from tensorflow.keras.layers import Conv2D, MaxPooling2D, BatchNormalization from tensorflow.keras.utils import to_categorical from tensorflow.keras.preprocessing.image .. 2021. 4. 10.
[CODE] ANN, K-fold CV, CNN 1. ANN ## Load Data from sklearn.model_selection import train_test_split X=df y=df_label.replace(2,0) X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.3, random_state=42) ## Build model import tensorflow as tf from tensorflow.keras.metrics import Precision, Recall model = tf.keras.models.Sequential([ tf.keras.layers.Dense(12, input_dim=69, activation='relu'), tf.keras.layers... 2021. 4. 10.
Flask 시작하기 Flask 시작하기 Flask run 0. flask의 구조 기본적으로 MVC(Model, View, Controller)구조가 가장 많이 쓰입니다. 사용자가 ROUTE를 통해 접근하면 Controller가 모델에서 데이터베이스에서 CRUD(Create,Read,Update,Delete)를해서 필요에 맞게 가져온뒤에 VIEW를 통하여 화면으로 나타내줍니다. Route는 사용자를 위해 만들어놓은 길같은 역할을 합니다. Controller가 취할 action이 되고 파이썬으로 쓰여집니다. Model은 스키마에따라 만들고 db에 형식에 맞게 저장될 수 있도록 만듭니다. Flask-Sqlalchemy와 flask migration으로 관리합니다. View는 Html,css,js,Bootsrap,Jinja등으로 .. 2021. 4. 1.
트위터 API, tweepy 사용하기 트위터 API, tweepy 사용하기 tweepy 1. API KEY 받기 developer.twitter.com/en Use Cases, Tutorials, & Documentation Publish & analyze Tweets, optimize ads, & create unique customer experiences with the Twitter API, Twitter Ads API, & Twitter Embeds. Let's start building! developer.twitter.com 먼저 트위터의 개발자사이트에서 api사용신청을하고 consumer_key, consumer_secret, access_token, access_token_secret를 받는 것 부터 시작합니다. (중요) 모.. 2021. 3. 31.
weather API 사용하기 weather API 사용하기 openweathermap openweathermap.org/api Weather API - OpenWeatherMap Please sign up and use our fast and easy-to-work weather APIs for free. Look at our monthly subscriptions for more options rather than the Free account that we provide you. Read How to start first and enjoy using our powerful weather APIs. openweathermap.org openweathermap API를 이용하여 도시별 기상정보를 불러올 수 있습니다. 1. JSON으.. 2021. 3. 31.
Scraping (Beautiful Soup) Scraping (Beautiful Soup) Review 1. Scraping import re import requests from bs4 import BeautifulSoup BASE_URL = "https://movie.naver.com/movie" def get_page(page_url): page = requests.get(page_url) soup = BeautifulSoup(page.content, 'html.parser') return soup, page def scrape_by_review_num(movie_title, review_num): for i in range(page_range): review_to_update = get_reviews(movie_code, page_num=i.. 2021. 3. 16.
ORM (SQL Alchemy) ORM (SQL Alchemy) Review 1. Create Tables realationship : class 간 연결 backref : 상호간 연결 Indicates the string name of a property to be placed on the related mapper’s class that will handle this relationship in the other direction. The other property will be created automatically when the mappers are configured. Can also be passed as a backref() object to control the configuration of the new relatio.. 2021. 3. 16.
SQL DB with Python 간단사용법 SQL with Python 간단사용법 Mysql, sqlite3등 SQL DB에서 커서 사용법은 대부분 비슷합니다. 이 포스트에서는 psycopg2를 이용한 쿼리를 다루겠습니다. 아래 psycopg2.connect 를 이용해 connection 변수가 데이터베이스와 연결할 수 있도록 다음 변수들에 알맞은 정보를 담습니다 CONNECTION - host: 데이터베이스 호스트 주소를 입력합니다. - user: 데이터베이스 유저 정보를 입력합니다. - password: 데이터베이스 비밀번호를 입력합니다. - database: 데이터베이스 이름을 입력합니다. # PostgreSQL DB에 접근하기 위해서 # python에서는 psycopg2를 이용 import psycopg2 host = 'xxxx.db.el.. 2021. 3. 12.