MichaelRKessler Claude Fable 5 commited on
Commit
554cb9c
Β·
1 Parent(s): 1bbfb3e

Document parallel print, GIF export, and dependency workflow

Browse files

Update README for the line/tube visualization modes, Shape 1/2/3
source selection, the G1/Reference-motion generation toggles, valve-
based print/travel classification, and the Parallel Printing tab with
its Matplotlib GIF export. Add AGENTS notes on regenerating
requirements.txt after dependency changes and the CPU-only (Agg/Pillow)
rendering constraint for Hugging Face.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Files changed (2) hide show
  1. AGENTS.md +16 -0
  2. README.md +30 -4
AGENTS.md CHANGED
@@ -15,6 +15,22 @@
15
  - `uv sync` β€” install all dependencies from lockfile
16
  - `uv run pytest` β€” run tests
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  ## Hugging Face Deployment
19
 
20
  - `.stl` files must be tracked by Git LFS (`*.stl filter=lfs` in `.gitattributes`)
 
15
  - `uv sync` β€” install all dependencies from lockfile
16
  - `uv run pytest` β€” run tests
17
 
18
+ ## Dependencies
19
+
20
+ - After any `uv add` / `uv remove`, regenerate the Hugging Face requirements file or the deploy will not get the change β€” the Space installs from `requirements.txt`, not from `uv.lock`:
21
+ `uv export --format requirements.txt --no-hashes --no-dev --frozen --output-file requirements.txt`
22
+ - Commit `pyproject.toml`, `uv.lock`, and `requirements.txt` together when dependencies change.
23
+
24
+ ## Rendering Constraints (Hugging Face)
25
+
26
+ - Hugging Face Spaces run headless with no GPU/WebGL and no guaranteed `ffmpeg`.
27
+ - For any server-side image or animation rendering, use CPU-only paths: Matplotlib's `Agg` backend, GIF via Pillow.
28
+ - Avoid `kaleido` / Plotly static-image export (3D is extremely slow headless) and ffmpeg-dependent MP4 output. Both were tried and proved unreliable here; the parallel-print GIF export uses Matplotlib `Agg` instead.
29
+
30
+ ## Local Tooling
31
+
32
+ - `.claude/` (e.g. `launch.json` for the local preview server) is gitignored and not deployed.
33
+
34
  ## Hugging Face Deployment
35
 
36
  - `.stl` files must be tracked by Git LFS (`*.stl filter=lfs` in `.gitattributes`)
README.md CHANGED
@@ -10,7 +10,7 @@ short_description: Upload STLs, export TIFF stacks, and generate G-code.
10
 
11
  # STL to G-Code Gradio App
12
 
13
- This project provides a Gradio app that takes up to three uploaded STL files, shows interactive 3D viewers, slices each model along the Z axis, saves slices as TIFF images, generates G-code from those TIFF stacks, and lets you preview the resulting tool path.
14
 
15
  ## Prerequisites
16
 
@@ -48,7 +48,11 @@ Then open the local Gradio URL in your browser, upload STL files or load the bun
48
  - Exports a ZIP containing the generated TIFF images
49
  - Combines generated stacks into a reference TIFF stack
50
  - Converts generated TIFF ZIPs into G-code files with pressure, valve, and port settings per shape
51
- - Visualizes generated or uploaded G-code tool paths
 
 
 
 
52
 
53
  ## Behavior and Implementation Notes
54
 
@@ -73,14 +77,36 @@ When you click **Generate Reference TIFF Stack**, the app combines available TIF
73
  - The app generates print/feed moves from material pixels and travel moves between material regions.
74
  - Generated files include pressure preset commands and WAGO valve commands based on the selected pressure, valve, and port.
75
  - Pressure increases by `0.1` psi per layer by default.
 
 
 
 
 
 
 
 
 
 
 
76
 
77
  ### G-code Visualization
78
 
79
- The G-code visualization tab can render either the generated Shape 1 G-code or an uploaded `.txt`, `.gcode`, or `.nc` file. It parses `G0` and `G1` movement lines, supports relative (`G91`) and absolute (`G90`) positioning, and displays travel and print segments with separate colors and opacity controls.
 
 
 
 
 
 
 
 
 
80
 
81
  ## Dependency Updates
82
 
83
- When dependencies change, update the lockfile and refresh the Hugging Face `requirements.txt` export:
 
 
84
 
85
  ```powershell
86
  uv sync --all-groups
 
10
 
11
  # STL to G-Code Gradio App
12
 
13
+ This project provides a Gradio app that takes up to three uploaded STL files, shows interactive 3D viewers, slices each model along the Z axis, saves slices as TIFF images, generates G-code from those TIFF stacks, previews the resulting tool path (a fast line plot or an animated 3D tube plot), and can visualize all three shapes printing in parallel and export that animation as a GIF.
14
 
15
  ## Prerequisites
16
 
 
48
  - Exports a ZIP containing the generated TIFF images
49
  - Combines generated stacks into a reference TIFF stack
50
  - Converts generated TIFF ZIPs into G-code files with pressure, valve, and port settings per shape
51
+ - Offers two G-code generation options: **Use G1 for all moves** (no rapid travel command) and **Use Reference Stack for motion** (all shapes share one nozzle path; each dispenses only its own geometry)
52
+ - Previews each shape's generated G-code inline (text boxes under the downloads)
53
+ - Visualizes generated or uploaded G-code tool paths, with the source selectable from Shape 1/2/3 or an uploaded file
54
+ - Renders the tool path as a fast line plot or an animated 3D tube plot (play/pause, speed, scrub, frame-step, nozzle marker)
55
+ - Plots all three shapes side by side (offset in X) and animates them printing in parallel, with a server-side GIF export of that animation
56
 
57
  ## Behavior and Implementation Notes
58
 
 
77
  - The app generates print/feed moves from material pixels and travel moves between material regions.
78
  - Generated files include pressure preset commands and WAGO valve commands based on the selected pressure, valve, and port.
79
  - Pressure increases by `0.1` psi per layer by default.
80
+ - **Use G1 for all moves**: when enabled, every movement line is emitted as `G1` (no `G0` rapid travel); the WAGO valve still marks where material is dispensed. Applies to all shapes.
81
+ - **Use Reference Stack for motion**: when enabled, every shape's snake-path *motion* is taken from the combined Reference TIFF Stack while each shape's *valve/dispensing* comes from its own slices β€” so parallel print heads share one synchronized nozzle path and each deposits only its own geometry. Requires generating the Reference TIFF Stack on the first tab first; shapes are skipped with a message if it is missing.
82
+
83
+ ### Print vs Travel Classification
84
+
85
+ When parsing G-code for visualization, the app decides print vs travel as follows:
86
+
87
+ - If the file contains `WAGO_ValveCommands`, the valve state (open/closed) determines print vs travel. This overrides `G0`/`G1`, because some generators emit every move as `G1`, or invert `G0`/`G1` relative to the valve.
88
+ - Otherwise it falls back to the convention `G1` = print, `G0` = travel.
89
+
90
+ The parser also handles standard slicer G-code: single-axis and Z-only moves, axes in any order, and `F`/`E` tokens (feed rate, extrusion) are ignored for geometry.
91
 
92
  ### G-code Visualization
93
 
94
+ The G-code visualization tab renders the generated Shape 1/2/3 G-code or an uploaded `.txt`, `.gcode`, or `.nc` file. It parses `G0`/`G1` movement lines, supports relative (`G91`) and absolute (`G90`) positioning, and offers two render modes:
95
+
96
+ - **Line Plot** β€” fast thin scatter lines (print and travel), with color/opacity controls.
97
+ - **Tube Plot with Animation** β€” mm-width filament tubes (circular, capped, lit) with a client-side build animation (play/pause, speed, scrub, frame-step) and a moving nozzle marker. Filament/travel widths default to the layer height and its quarter.
98
+
99
+ ### Parallel Printing Visualization
100
+
101
+ The fourth tab plots all three shapes' G-code at once, offset along X so they do not overlap, each in its own color. Like the visualization tab it has a fast **Line Plot** and an animated **Tube Plot**; the animation advances all parts on a shared cumulative-path-length timeline, so a shorter part finishes first.
102
+
103
+ It can also **export the animation as a GIF**, rendered server-side with Matplotlib (the `Agg` CPU backend β€” no WebGL, no headless browser, and no `ffmpeg`, so it works locally and on Hugging Face). The GIF is line-style with faint grey travel and white, black-outlined nozzle markers drawn on top; controls cover duration, frames per second, elevation/azimuth viewing angle, and travel opacity (0 hides travel).
104
 
105
  ## Dependency Updates
106
 
107
+ The parallel-print GIF export requires `matplotlib` (rendered with the CPU `Agg` backend so it runs on Hugging Face).
108
+
109
+ When dependencies change, update the lockfile and refresh the Hugging Face `requirements.txt` export β€” the Space installs from `requirements.txt`, not from the lockfile:
110
 
111
  ```powershell
112
  uv sync --all-groups