feat: sync all remaining python source board configurations
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='sprite',
|
||||
version='0.0.1',
|
||||
packages=find_packages(),
|
||||
install_requires=[],
|
||||
author='Mixly Team',
|
||||
author_email='',
|
||||
description='适用于pyodide的sprite包',
|
||||
classifiers=[
|
||||
'Programming Language :: Python :: 3',
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,120 @@
|
||||
from js import window
|
||||
|
||||
|
||||
def createBackground(img):
|
||||
return window.mixlySprite.createBackground(img)
|
||||
|
||||
|
||||
class Sprite:
|
||||
def __init__(self, img, x, y, name=''):
|
||||
self.vname = window.mixlySprite.createASprite(img, x, y, name)
|
||||
|
||||
@property
|
||||
def this(self):
|
||||
return window.mixlySprite.sprites.__getattribute__(self.vname)
|
||||
|
||||
def show(self):
|
||||
return self.this.show()
|
||||
|
||||
def hide(self):
|
||||
return self.this.hide()
|
||||
|
||||
def enlarge(self):
|
||||
return self.this.enlarge()
|
||||
|
||||
def enlargeTo(self, s):
|
||||
return self.this.enlargeTo(s)
|
||||
|
||||
def expandTo(self, s, time):
|
||||
return self.this.expandTo(s, time)
|
||||
|
||||
def move(self, step):
|
||||
return self.this.move(step)
|
||||
|
||||
def moveTo(self, x, y):
|
||||
return self.this.moveTo(x, y)
|
||||
|
||||
async def slideTo(self, x, y, time):
|
||||
return await self.this.slideTo(x, y, time)
|
||||
|
||||
def addX(self, step):
|
||||
return self.this.addX(step)
|
||||
|
||||
def addY(self, step):
|
||||
return self.this.addY(step)
|
||||
|
||||
def getX(self):
|
||||
return self.this.getX()
|
||||
|
||||
def getY(self):
|
||||
return self.this.getY()
|
||||
|
||||
def rotate(self, degree):
|
||||
return self.this.rotate(degree)
|
||||
|
||||
def rotateTo(self, degree):
|
||||
return self.this.rotateTo(degree)
|
||||
|
||||
def circleTo(self, degree):
|
||||
return self.this.circleTo(degree)
|
||||
|
||||
def hit(self, sprite2):
|
||||
return self.this.hit(sprite2.this)
|
||||
|
||||
def outOfScreen(self):
|
||||
return self.this.outOfScreen()
|
||||
|
||||
def mouseAction(self, calc):
|
||||
return self.this.mouseAction(calc)
|
||||
|
||||
def isClicked(self):
|
||||
return self.this.isDown
|
||||
|
||||
def setScale(self, h, w):
|
||||
return self.this.setScale(h, w)
|
||||
|
||||
def filterGray(self):
|
||||
return self.this.filterGray()
|
||||
|
||||
def filterBrighter(self):
|
||||
return self.this.filterBrighter()
|
||||
|
||||
def filterOrigin(self):
|
||||
return self.this.filterOrigin()
|
||||
|
||||
|
||||
class Text:
|
||||
def __init__(self, text, x, y, name=''):
|
||||
self.vname = window.mixlySprite.createText(text, x, y, name)
|
||||
|
||||
@property
|
||||
def this(self):
|
||||
return window.mixlySprite.texts.__getattribute__(self.vname)
|
||||
|
||||
def changeText(self, text):
|
||||
return self.this.changeText(text)
|
||||
|
||||
def show(self):
|
||||
return self.this.show()
|
||||
|
||||
def hide(self):
|
||||
return self.this.hide()
|
||||
|
||||
|
||||
def clearAllSprites():
|
||||
return window.mixlySprite.clearAllSprites()
|
||||
|
||||
def repeat(calc):
|
||||
return window.mixlySprite.repeat(calc)
|
||||
|
||||
def keyboardListener(calc):
|
||||
return window.mixlySprite.keyboardListener(key, calc)
|
||||
|
||||
def isKeyboardHit(keyvalue):
|
||||
return window.mixlySprite.isKeyboardHit(keyvalue)
|
||||
|
||||
def getTime():
|
||||
return window.mixlySprite.timer / 1000
|
||||
|
||||
def clearTimer():
|
||||
return window.mixlySprite.clearTimer()
|
||||
@@ -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