nicolamustone commited on
Commit
ef3fe89
·
1 Parent(s): 8b96c76

Add mini-pricing.py script and update README

Browse files

Introduces mini-pricing.py, a script that calculates total cost per miniature from STL feature CSVs, using resin cost and overhead constants. Updates the README with usage instructions for both stl-scanner.py and mini-pricing.py.

Files changed (2) hide show
  1. README.md +21 -3
  2. mini-pricing.py +36 -0
README.md CHANGED
@@ -116,8 +116,9 @@ Weights are cached locally by `huggingface_hub` after the first download.
116
 
117
  ## CLI: Extract STL features with `trimesh`
118
 
119
- This project includes a small command-line script that scans STL files and exports geometric features to a CSV using `trimesh`.
120
- The resulting CSV file is ready-to-use with MiniRes.
 
121
 
122
  ### Script: `stl-scanner.py`
123
 
@@ -161,11 +162,28 @@ python stl-scaner.py --stl_path /path/to/model.stl --output_path ./out
161
 
162
  Process all STL files in a folder (non-recursive) and save the CSV to ./features:
163
  ```bash
164
- python extract_stl_features.py --stl_path /path/to/stls --output_path ./features
165
  ```
166
 
167
  After running the script, you’ll find `stl_features.csv` in the `output_path` folder, ready to be used as input for MiniRes or for your own analysis.
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  ## MIT License
171
 
 
116
 
117
  ## CLI: Extract STL features with `trimesh`
118
 
119
+ This project includes two small command-line scripts:
120
+ 1. `stl-scanner.py`: scans STL files and exports geometric features to a CSV using `trimesh`. The resulting CSV file is ready-to-use with MiniRes.
121
+ 2. `mini-pricing.py`: takes the resulting CSV from `stl-scanner.py` (or any other CSV) and calculates the total cost of each file for you.
122
 
123
  ### Script: `stl-scanner.py`
124
 
 
162
 
163
  Process all STL files in a folder (non-recursive) and save the CSV to ./features:
164
  ```bash
165
+ python stl-scaner.py --stl_path /path/to/stls --output_path ./features
166
  ```
167
 
168
  After running the script, you’ll find `stl_features.csv` in the `output_path` folder, ready to be used as input for MiniRes or for your own analysis.
169
 
170
+ ### Script: `mini-pricing.py`
171
+
172
+ Open the file with a text editor and adjust the constants at the top:
173
+ ```python
174
+ RESIN_COST_PER_GRAM = 0.06 # in your currency, e.g. 0.06 = €0.06/gram
175
+ OVERHEAD_PER_MINI = 1.50 # fixed overhead per miniature (packaging, time, etc.)
176
+ INPUT_CSV = Path("stl_features.csv")
177
+ OUTPUT_CSV = Path("mini_pricing.csv")
178
+ ```
179
+
180
+ Run the script via terminal:
181
+ ```bash
182
+ python mini-pricing.py
183
+ ```
184
+
185
+ and inspect the resulting `minipricing.csv` for a list of all your miniatures, with their total cost.
186
+
187
 
188
  ## MIT License
189
 
mini-pricing.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path
2
+
3
+ import pandas as pd
4
+ from minires import minires
5
+
6
+ # ==== Edit these numbers for your context ====
7
+ RESIN_COST_PER_GRAM = 0.06 # in your currency, e.g. 0.06 = €0.06/gram
8
+ OVERHEAD_PER_MINI = 1.50 # fixed overhead per miniature (packaging, time, etc.)
9
+ INPUT_CSV = Path("stl_features.csv")
10
+ OUTPUT_CSV = Path("mini_pricing.csv")
11
+ # =============================================
12
+
13
+ def main() -> None:
14
+ if not INPUT_CSV.exists():
15
+ raise SystemExit(f"Input CSV not found: {INPUT_CSV}. "
16
+ "Run stl-scanner.py first.")
17
+
18
+ # Load STL features produced by stl-scanner.py
19
+ df = pd.read_csv(INPUT_CSV)
20
+
21
+ # Create MiniRes ensemble model
22
+ model = minires(verbose=0)
23
+
24
+ # Predict resin usage in grams
25
+ grams = model.predict(df)
26
+
27
+ df["predicted_grams"] = grams
28
+ df["resin_cost"] = df["predicted_grams"] * RESIN_COST_PER_GRAM
29
+ df["overhead"] = OVERHEAD_PER_MINI
30
+ df["total_cost"] = df["resin_cost"] + df["overhead"]
31
+
32
+ df.to_csv(OUTPUT_CSV, index=False)
33
+ print(f"Wrote pricing table to {OUTPUT_CSV.resolve()}")
34
+
35
+ if __name__ == "__main__":
36
+ main()