하단 광고


손글씨를 폰트로 교환하는 방법 by 설악이

올해 멘토링 시작 과제.. 
일단 아래 샘플을 직접 구동해서 결과까지 보는걸로...

일단 설치는... 아래 사항을 따라서 하면 됩니다. 싸이트에 있는데로 ^^;
1
2
3
4
5
6
7
8
9
install dependencies (see below).
download the repo
navigate to the repo in bash
download and unzip folder containing pretrained models: https://goo.gl/qbH2uw
place in this directory
Now you have two options:
 
Run the sampler in bash: mkdir -p ./logs/figures && python run.py --sample --tsteps 700
Open the sample.ipynb jupyter notebook and run cell-by-cell (it includes equations and text to explain how the model works)
cs


뭐.. 간단히 설명하면
1. git clone https://github.com/greydanus/scribe.git 로 코드를 다운받습니다.
2. https://goo.gl/qbH2uw 에서 다운로드후 git clone 한 폴더에 압축을 풉니다. 
    $tar xzvf saved.tgz
3. 아래를 실행합니다. 
    $mkdir -p ./logs/figures && python run.py --sample --tsteps 700

컥.. 아래 같은 에러가.. .
1
2
3
4
5
Traceback (most recent call last):
  File "run.py", line 1in <module>
    import numpy as np
ImportError: No module named numpy
 
cs

긴장하지 마시구.. phython에서 필요한 numpy가 안깔려서 그런거죠. ^^;

인터넷 찾아보니 아래를 실행하라고 합니다.. 
sudo apt-get install python-pip  sudo pip install numpy scipy
자.. 실행합니다..
1
2
3
4
5
~/test/handwrite$ mkdir -p ./logs/figures && python run.py --sample --tsteps 700
Traceback (most recent call last):
  File "run.py", line 2in <module>
    import tensorflow as tf
ImportError: No module named tensorflow
cs


아 이번에는 tf가 없다고 하네요.. tensorflow

그럼 어쩌죠?? 설치하면 되죠 모. ^^

앗 그런데 github에 아래와 같은 내용이 있네요. ㅡ.ㅡ; 처음부터 읽고 할껄 ㅡ.ㅡ;

Dependencies

  • All code is written in python 2.7. You will need:
  • Numpy
  • Matplotlib
  • TensorFlow 1.0
  • OPTIONAL: Jupyter (if you want to run sample.ipynb and dataloader.ipynb)

일단 Numpy는 우연치 않게 설치는 했구요..
나머지들을 설치해야 하는데.. Matplotlib와 TensorFlow 1.0을 깔아야 하네요.. (움 현재 제 PC에 있는 python version도 확인이 필요해 보입니다. ㅡ.ㅡ)

움.. 일단  python version check 하려는데.. Unbuntu 16.04를 쓰는데 설치가 되어 있네요..
다행이 python2.7도 설치가 되어 있네요 ^^; 그럼 이건  패스.. 

그럼 다음은 Matplotlib 인가요? 뭐.. 구글에서 검색하면.. 

Before you start - do not forget to remove python-matplotlib with
sudo apt-get purge python-matplotlib.

Then you may try to install matplotlib-2.1.0 with pip:

  • sudo pip install matplotlib (for python2.7)
  • sudo pip3 install matplotlib (for python3.5).

움.. 요약하면... 아래 두개를 하라는거군요.. (우리는 python 2.7을 사용할꺼니까 ^^;)
$sudo apt-get purge python-matplotlib    <<< 요건 설치가 이미 되어 있어서 저는 패스 하네요 ^^;
$sudo pip install matplotlib 

자 그럼 이제 남은건 TensorFlow1.0 이네요 ^6;
찾아보니 친절한 블로그 분들이 많네요 ^^;


자.. 뭐 해볼까요?
아.. 그래픽카드 그러니까.. GPU 사용하는건.. 패스해보고 싶다. .속도 안나와도 되니까.. 동작만되게..

그럼.. 아래 명령만 치면 되는듯 ^^
$pip install tensorflow

오 설치이후 실행하니까.. 진행이 되긴하네요. ^^;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
younlea@sulac:~/test/handwrite$ mkdir -p ./logs/figures && python run.py --sample --tsteps 700
 
SAMPLING MODE...
loading data...
building model...
        using alphabet abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
WARNING:tensorflow:From /home/younlea/.local/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/base.py:198: retry (from tensorflow.contrib.learn.python.learn.datasets.base) is deprecated and will be removed in a future version.
Instructions for updating:
Use the retry module or similar alternatives.
WARNING:tensorflow:From /home/younlea/test/handwrite/model.py:80: calling reduce_sum (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
2018-04-27 08:28:15.828429: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
attempt to load saved model...
2018-04-27 08:28:15.899510: W tensorflow/core/framework/op_kernel.cc:1273] OP_REQUIRES failed at save_restore_v2_ops.cc:184 : Not found: Key cell0/lstm_cell/bias not found in checkpoint
no saved model to load. starting new session
load failed, sampling canceled
 
cs

자.. 이제 남은건? tensorflow쪽 코드가 무언가 맞지 않나 보네요.. 찾아보도록 하죠 ^^;



덧글

댓글 입력 영역