feat: sync all remaining python source board configurations
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from pyodide.ffi import to_js, create_proxy
|
||||
import js
|
||||
import json
|
||||
import os
|
||||
from . import layers
|
||||
|
||||
|
||||
def __cache_model(file_path):
|
||||
data = json.load(open(file_path, 'r'))
|
||||
f = open(file_path, 'rb')
|
||||
js.tensorflow.setModelsValue(file_path, to_js(f.read()))
|
||||
f.close()
|
||||
folder_path = os.path.dirname(file_path)
|
||||
for item in data['weightsManifest']:
|
||||
for current_path in item['paths']:
|
||||
bin_file_path = '{}/{}'.format(folder_path, current_path)
|
||||
f = open(bin_file_path, 'rb')
|
||||
js.tensorflow.setModelsValue(bin_file_path, to_js(f.read()))
|
||||
f.close()
|
||||
|
||||
|
||||
async def load_graph_model(file_path):
|
||||
__cache_model(file_path)
|
||||
model = await js.tensorflow.loadGraphModel(file_path)
|
||||
return model
|
||||
|
||||
|
||||
async def load_layers_model(file_path):
|
||||
__cache_model(file_path)
|
||||
model = await js.tensorflow.loadLayersModel(file_path)
|
||||
return model
|
||||
|
||||
def tensor(data):
|
||||
return js.tf.tensor(to_js(data))
|
||||
|
||||
def sequential():
|
||||
return js.tf.sequential()
|
||||
|
||||
async def load_model(name):
|
||||
model = await js.tf.loadLayersModel(f"indexeddb://{name}")
|
||||
return model
|
||||
|
||||
async def prepare_qmyixtxi(imgTensor):
|
||||
return await js.prepare_qmyixtxi(imgTensor)
|
||||
@@ -0,0 +1,5 @@
|
||||
from .activation import *
|
||||
from .core import *
|
||||
|
||||
from pyodide.ffi import to_js, create_proxy
|
||||
import js
|
||||
@@ -0,0 +1,37 @@
|
||||
import js
|
||||
|
||||
|
||||
def elu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0.
|
||||
'''
|
||||
js.tensorflow.layers.elu(*args, **kwargs)
|
||||
|
||||
|
||||
def leaky_relu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = alpha * x for x < 0. f(x) = x for x >= 0.
|
||||
'''
|
||||
js.tensorflow.layers.leakyReLU(*args, **kwargs)
|
||||
|
||||
|
||||
def prelu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = alpha * x for x < 0. f(x) = x for x >= 0.
|
||||
'''
|
||||
js.tensorflow.layers.prelu(*args, **kwargs)
|
||||
|
||||
|
||||
def relu(*args, **kwargs):
|
||||
js.tensorflow.layers.relu(*args, **kwargs)
|
||||
|
||||
|
||||
def softmax(*args, **kwargs):
|
||||
js.tensorflow.layers.softmax(*args, **kwargs)
|
||||
|
||||
|
||||
def thresholded_relu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = x for x > theta, f(x) = 0 otherwise.
|
||||
'''
|
||||
js.tensorflow.layers.thresholdedReLU(*args, **kwargs)
|
||||
@@ -0,0 +1,5 @@
|
||||
import js
|
||||
from pyodide.ffi import to_js
|
||||
|
||||
def dense(units, input_shape=None):
|
||||
return js.tf.layers.dense(units=units, inputShape=to_js(input_shape))
|
||||
@@ -0,0 +1,14 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='tensorflow',
|
||||
version='0.0.1',
|
||||
packages=find_packages(),
|
||||
install_requires=[],
|
||||
author='Mixly Team',
|
||||
author_email='',
|
||||
description='适用于pyodide的tensorflowjs包',
|
||||
classifiers=[
|
||||
'Programming Language :: Python :: 3',
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
Metadata-Version: 2.4
|
||||
Name: tensorflow
|
||||
Version: 0.0.1
|
||||
Summary: 适用于pyodide的tensorflowjs包
|
||||
Author: Mixly Team
|
||||
Author-email:
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Dynamic: author
|
||||
Dynamic: classifier
|
||||
Dynamic: summary
|
||||
@@ -0,0 +1,10 @@
|
||||
setup.py
|
||||
tensorflow/__init__.py
|
||||
tensorflow.egg-info/PKG-INFO
|
||||
tensorflow.egg-info/SOURCES.txt
|
||||
tensorflow.egg-info/dependency_links.txt
|
||||
tensorflow.egg-info/top_level.txt
|
||||
tensorflow/layers/__init__.py
|
||||
tensorflow/layers/activation.py
|
||||
tensorflow/layers/base.py
|
||||
tensorflow/layers/core.py
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
tensorflow
|
||||
@@ -0,0 +1,44 @@
|
||||
from pyodide.ffi import to_js, create_proxy
|
||||
import js
|
||||
import json
|
||||
import os
|
||||
from . import layers
|
||||
|
||||
|
||||
def __cache_model(file_path):
|
||||
data = json.load(open(file_path, 'r'))
|
||||
f = open(file_path, 'rb')
|
||||
js.tensorflow.setModelsValue(file_path, to_js(f.read()))
|
||||
f.close()
|
||||
folder_path = os.path.dirname(file_path)
|
||||
for item in data['weightsManifest']:
|
||||
for current_path in item['paths']:
|
||||
bin_file_path = '{}/{}'.format(folder_path, current_path)
|
||||
f = open(bin_file_path, 'rb')
|
||||
js.tensorflow.setModelsValue(bin_file_path, to_js(f.read()))
|
||||
f.close()
|
||||
|
||||
|
||||
async def load_graph_model(file_path):
|
||||
__cache_model(file_path)
|
||||
model = await js.tensorflow.loadGraphModel(file_path)
|
||||
return model
|
||||
|
||||
|
||||
async def load_layers_model(file_path):
|
||||
__cache_model(file_path)
|
||||
model = await js.tensorflow.loadLayersModel(file_path)
|
||||
return model
|
||||
|
||||
def tensor(data):
|
||||
return js.tf.tensor(to_js(data))
|
||||
|
||||
def sequential():
|
||||
return js.tf.sequential()
|
||||
|
||||
async def load_model(name):
|
||||
model = await js.tf.loadLayersModel(f"indexeddb://{name}")
|
||||
return model
|
||||
|
||||
async def prepare_qmyixtxi(imgTensor):
|
||||
return await js.prepare_qmyixtxi(imgTensor)
|
||||
@@ -0,0 +1,5 @@
|
||||
from .activation import *
|
||||
from .core import *
|
||||
|
||||
from pyodide.ffi import to_js, create_proxy
|
||||
import js
|
||||
@@ -0,0 +1,37 @@
|
||||
import js
|
||||
|
||||
|
||||
def elu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = alpha * (exp(x) - 1.) for x < 0, f(x) = x for x >= 0.
|
||||
'''
|
||||
js.tensorflow.layers.elu(*args, **kwargs)
|
||||
|
||||
|
||||
def leaky_relu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = alpha * x for x < 0. f(x) = x for x >= 0.
|
||||
'''
|
||||
js.tensorflow.layers.leakyReLU(*args, **kwargs)
|
||||
|
||||
|
||||
def prelu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = alpha * x for x < 0. f(x) = x for x >= 0.
|
||||
'''
|
||||
js.tensorflow.layers.prelu(*args, **kwargs)
|
||||
|
||||
|
||||
def relu(*args, **kwargs):
|
||||
js.tensorflow.layers.relu(*args, **kwargs)
|
||||
|
||||
|
||||
def softmax(*args, **kwargs):
|
||||
js.tensorflow.layers.softmax(*args, **kwargs)
|
||||
|
||||
|
||||
def thresholded_relu(*args, **kwargs):
|
||||
'''
|
||||
f(x) = x for x > theta, f(x) = 0 otherwise.
|
||||
'''
|
||||
js.tensorflow.layers.thresholdedReLU(*args, **kwargs)
|
||||
@@ -0,0 +1,5 @@
|
||||
import js
|
||||
from pyodide.ffi import to_js
|
||||
|
||||
def dense(units, input_shape=None):
|
||||
return js.tf.layers.dense(units=units, inputShape=to_js(input_shape))
|
||||
Reference in New Issue
Block a user