product-diagrams / scripts /lane28_polymath.py
Architect-Prime's picture
Upload scripts/lane28_polymath.py with huggingface_hub
b5f5432 verified
"""Lane 28: Polymath-AI — on-device LLM training (Snapdragon 8 Elite).
Key visual: layered neural network — input/hidden/output columns with all-to-all connections.
"""
import sys, os
sys.path.insert(0, os.path.dirname(__file__))
from render_protocol import (
clean_scene, add_wireframe, set_fill_as_occluder,
setup_world, render_2x, W2X, H2X, WIRE_COLOR,
)
import bpy, math
OUT_2X = "/Users/Zer0pa/ZPE/ZPE-Animation-Workspace/blender-proto/lane28_polymath_2x.png"
OUT_FINAL = "/Users/Zer0pa/ZPE/ZPE-Animation-Workspace/final-572x534/key-visuals/lane28_Polymath-AI.png"
scene = clean_scene()
# Network: 4 layers — 6, 8, 8, 5 nodes
LAYERS = [6, 8, 8, 5]
LAYER_GAP = 0.9
NODE_R = 0.10
# Compute node positions: each layer is a vertical column
nodes_by_layer = []
total_w = (len(LAYERS) - 1) * LAYER_GAP
for li, n in enumerate(LAYERS):
x = -total_w/2 + li * LAYER_GAP
col_h = 2.0
cz = []
for i in range(n):
if n == 1:
z = 0
else:
z = -col_h/2 + i * col_h/(n-1)
cz.append(z)
nodes_by_layer.append([(x, 0, z) for z in cz])
# Build node spheres
for li, layer in enumerate(nodes_by_layer):
for ni, p in enumerate(layer):
bpy.ops.mesh.primitive_uv_sphere_add(segments=14, ring_count=8, radius=NODE_R, location=p)
s = bpy.context.active_object
s.name = f"N_{li}_{ni}"
bpy.context.view_layer.update()
set_fill_as_occluder(s)
add_wireframe(s, thickness_factor=0.014)
# Connections: layer to layer, all-to-all
conn_curve = bpy.data.curves.new("Conn", type='CURVE'); conn_curve.dimensions = '3D'
conn_curve.bevel_depth = 0.006
for li in range(len(LAYERS) - 1):
for src in nodes_by_layer[li]:
for dst in nodes_by_layer[li + 1]:
sp = conn_curve.splines.new('POLY'); sp.points.add(1)
sp.points[0].co = (*src, 1.0); sp.points[1].co = (*dst, 1.0)
conn = bpy.data.objects.new("Conn", conn_curve); scene.collection.objects.link(conn)
mat = bpy.data.materials.new("CMat"); mat.use_nodes = True
nt = mat.node_tree
for n in list(nt.nodes): nt.nodes.remove(n)
out = nt.nodes.new("ShaderNodeOutputMaterial")
emi = nt.nodes.new("ShaderNodeEmission")
emi.inputs["Color"].default_value = (0.55, 0.56, 0.58, 1.0) # slightly dimmer than nodes
emi.inputs["Strength"].default_value = 1.6
nt.links.new(emi.outputs[0], out.inputs[0])
conn.data.materials.append(mat)
setup_world()
target = bpy.data.objects.new("Target", None); target.location = (0, 0, 0)
scene.collection.objects.link(target)
cam_data = bpy.data.cameras.new("Cam"); cam_data.lens = 50
cam_data.clip_start = 0.001
cam = bpy.data.objects.new("Cam", cam_data); scene.collection.objects.link(cam)
half_fov = math.atan((36/2) / 50)
content_w = total_w + 0.4
content_h = 2.4
dist = max(content_w, content_h * 1.07) / 2 / math.tan(half_fov) * 1.10
cam.location = (0, -dist, 0)
trk = cam.constraints.new('TRACK_TO')
trk.target = target; trk.track_axis = 'TRACK_NEGATIVE_Z'; trk.up_axis = 'UP_Y'
scene.camera = cam
print(f"[lane28] rendering → {OUT_2X}")
render_2x(OUT_2X)
print(f"[lane28] done")