Skip to content

tensorflow => tensorflow.js 변환에 대해 질문드립니다. #1140

Description

@donhaklee

안녕하세요! 어제까지 야학 공부를 끝낸 학생입니다.
1주 전에 그림<=>사진 웹 프로그램을 만들기 위해 질문드렸고
도움이 되는 자료를 많이 주셨는데 활용을 못해서
1주간 열심히 시도해봤지만 실패하여 염치없이 다시 질문하게 되었습니다..ㅠ

# 해결하고자 하는 문제
https://www.tensorflow.org/tutorials/generative/style_transfer
해당 사이트의 파이썬 코드를
teachable machine에 tensorflow와 tensorflow.js가 있듯이
자바스크립트 코드로 변환해보려 시도를 했는데 잘 안되어 질문드립니다.

https://www.tensorflow.org/js/tutorials/conversion/import_keras?hl=ko
https://www.youtube.com/watch?v=yWBM2-Rx47M
우선 해당 사이트와 유튜브를 참고하며
파이썬을 자바스크립트로 바꾸는 작업을 1주일동안 찾아가며 해보는 중인데
정말 해결이 안돼서 어렵네요 ㅠ 답도 다 나와있는데 말이죠...

# 코드 혹은 오류

<해당 방법으로는 model.json 생성에 성공했지만 경로 입력시 오류가 발생했습니다.>
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(4, input_dim=2, activation='tanh'))
model.add(tf.keras.layers.Dense(1, activation='sigmoid'))
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['binary_accuracy'])
tfjs.converters.save_keras_model(model,'models')

tensorflowjs_converter --input_format keras \C:\Users\User\Desktop\picturetophoto\model.json \C:\Users\User\Desktop\picturetophoto

에러 : ValueError: Nonexistent path to HDF5 file: \C:\Users\User\Desktop\picturetophoto\models\model.json

<.h5를 생성하는 해당방법엔 해당오류가 있었습니다>
model = tf.keras.models.Sequential()
model.save('C:\Users\User\Desktop\picturetophoto')

에러 : File "c:\Users\User\Desktop\picturetophoto\model.py", line 74 -3: truncated \UXXXXXXXX escape
model.save('C:\Users\User\Desktop\picturetophoto') ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

이렇게 2가지 방향으로 변환을 시키려 시도했는데 둘 다 잘 안되어 질문드립니다.

되도록 json을 로드하는 방법이 아닌 자바스크립트 코드로 바꿔 수정이 가능하도록 하고 싶은데 혹시 방법이 있을까요??

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ML / DLmachine learning, deep learning

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions